Commit 439120b6 by Matt

highlight center grid in touch area

parent d68283ed
...@@ -5,6 +5,7 @@ const gridsInY = 10 ...@@ -5,6 +5,7 @@ const gridsInY = 10
class Map extends egret.Sprite { class Map extends egret.Sprite {
private grids:any = [] private grids:any = []
private touchArea: egret.Bitmap private touchArea: egret.Bitmap
private isShowingTouchArea
public constructor() { public constructor() {
super(); super();
this.init() this.init()
...@@ -30,8 +31,8 @@ class Map extends egret.Sprite { ...@@ -30,8 +31,8 @@ class Map extends egret.Sprite {
} }
public getSurroundedGrids(x, y) { public getSurroundedGrids(x, y) {
const left = Math.max(x / gridWidth - 2) const left = x / gridWidth - 2
const top = Math.max(y / gridHeight - 2) const top = y / gridHeight - 2
const grids = [] const grids = []
for (let i = left; i < 5 + left; i++) { for (let i = left; i < 5 + left; i++) {
for (let j = top; j < 5 + top; j++) { for (let j = top; j < 5 + top; j++) {
...@@ -43,7 +44,12 @@ class Map extends egret.Sprite { ...@@ -43,7 +44,12 @@ class Map extends egret.Sprite {
return grids 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) const surroundedGrids = this.getSurroundedGrids(x, y)
surroundedGrids.forEach(grid => { surroundedGrids.forEach(grid => {
grid.alpha = 1 grid.alpha = 1
...@@ -53,10 +59,12 @@ class Map extends egret.Sprite { ...@@ -53,10 +59,12 @@ class Map extends egret.Sprite {
this.touchArea.y = y - 2 * gridHeight this.touchArea.y = y - 2 * gridHeight
setTimeout(() => { setTimeout(() => {
centerGrid.bg.texture = RES.getRes('grid_jpg')
surroundedGrids.forEach(grid => { surroundedGrids.forEach(grid => {
grid.alpha = 0 grid.alpha = 0
}) })
this.touchArea.alpha = 0 this.touchArea.alpha = 0
this.isShowingTouchArea = false
}, 1000); }, 1000);
} }
......
class MapGrid extends egret.Sprite { class MapGrid extends egret.Sprite {
private bg:egret.Bitmap = new egret.Bitmap() public bg:egret.Bitmap = new egret.Bitmap()
public constructor() { public constructor() {
super(); super();
this.init() this.init()
...@@ -18,7 +18,7 @@ class MapGrid extends egret.Sprite { ...@@ -18,7 +18,7 @@ class MapGrid extends egret.Sprite {
private onTouchTap() { private onTouchTap() {
if (Store.isCatcher()) { 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