Commit 9ff81dfe by Matt

Merge branch 'develop-matt' into develop

parents f564fe0c 439120b6
......@@ -5,6 +5,7 @@ const gridsInY = 10
class Map extends egret.Sprite {
private grids:any = []
private touchArea: egret.Bitmap
private isShowingTouchArea
public constructor() {
super();
this.init()
......@@ -30,8 +31,8 @@ class Map extends egret.Sprite {
}
public getSurroundedGrids(x, y) {
const left = Math.max(x / gridWidth - 2)
const top = Math.max(y / gridHeight - 2)
const left = x / gridWidth - 2
const top = y / gridHeight - 2
const grids = []
for (let i = left; i < 5 + left; i++) {
for (let j = top; j < 5 + top; j++) {
......@@ -43,7 +44,12 @@ class Map extends egret.Sprite {
return grids
}
public showSurroundedGrids(x, y) {
public showSurroundedGrids(x, y, centerGrid) {
if (this.isShowingTouchArea) {
return
}
this.isShowingTouchArea = true
centerGrid.bg.texture = RES.getRes('grid_select_jpg')
const surroundedGrids = this.getSurroundedGrids(x, y)
surroundedGrids.forEach(grid => {
grid.alpha = 1
......@@ -53,10 +59,12 @@ class Map extends egret.Sprite {
this.touchArea.y = y - 2 * gridHeight
setTimeout(() => {
centerGrid.bg.texture = RES.getRes('grid_jpg')
surroundedGrids.forEach(grid => {
grid.alpha = 0
})
this.touchArea.alpha = 0
this.isShowingTouchArea = false
}, 1000);
}
......
class MapGrid extends egret.Sprite {
private bg:egret.Bitmap = new egret.Bitmap()
public bg:egret.Bitmap = new egret.Bitmap()
public constructor() {
super();
this.init()
......@@ -18,7 +18,7 @@ class MapGrid extends egret.Sprite {
private onTouchTap() {
if (Store.isCatcher()) {
this.parent.showSurroundedGrids(this.x, this.y)
this.parent.showSurroundedGrids(this.x, this.y, this)
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment