Commit ad398fb5 by Matt

fix hit test

parent 6c9718fa
...@@ -81,8 +81,9 @@ class Map extends egret.Sprite { ...@@ -81,8 +81,9 @@ class Map extends egret.Sprite {
public getCatchedRunners(x, y) { public getCatchedRunners(x, y) {
const catchedRunners = [] const catchedRunners = []
Store.getState().runners.forEach(runner => { Store.getState().runners.forEach(runner => {
if (runner.x === x && runner.y === y) { const updatedRunner = this.runnerMap[runner.t_cid]
catchedRunners.push(runner) if (updatedRunner.x === x && updatedRunner.y === y) {
catchedRunners.push(updatedRunner)
} }
}) })
return catchedRunners return catchedRunners
...@@ -103,7 +104,7 @@ class Map extends egret.Sprite { ...@@ -103,7 +104,7 @@ class Map extends egret.Sprite {
}) })
runners.forEach(runner => { runners.forEach(runner => {
if (this.touchArea.hitTestPoint(runner.x * gridWidth, runner.y * gridHeight)) { if (this.touchArea.hitTestPoint(runner.x * gridWidth, runner.y * gridHeight)) {
runner.alpha = 1 this.runnerMap[runner.t_cid].alpha = 1
} }
}) })
this.getCatchedRunners(x, y).forEach(runner => { this.getCatchedRunners(x, y).forEach(runner => {
...@@ -130,7 +131,7 @@ class Map extends egret.Sprite { ...@@ -130,7 +131,7 @@ class Map extends egret.Sprite {
grid.alpha = 0 grid.alpha = 0
}) })
runners.forEach(runner => { runners.forEach(runner => {
runner.alpha = 0 this.runnerMap[runner.t_cid].alpha = 0
}) })
this.touchArea.alpha = 0 this.touchArea.alpha = 0
this.isShowingTouchArea = false this.isShowingTouchArea = false
......
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