Commit faa48ffb by Matt

fix hit test

parent 65c2ac66
...@@ -33,10 +33,10 @@ class Map extends egret.Sprite { ...@@ -33,10 +33,10 @@ class Map extends egret.Sprite {
this.addChild(this.touchArea) this.addChild(this.touchArea)
Store.getState().runners.forEach(runnerData => { Store.getState().runners.forEach(runnerData => {
const runner = new Runner(runnerData) const runner = new Runner(runnerData)
this.addChild(runner)
if (Store.isCatcher()) { if (Store.isCatcher()) {
runner.alpha === 0 runner.alpha === 0
} }
this.addChild(runner)
this.runnerMap[runnerData.t_cid] = runner this.runnerMap[runnerData.t_cid] = runner
}) })
EventBus.addEventListener('moving', (payload) => { EventBus.addEventListener('moving', (payload) => {
...@@ -102,7 +102,8 @@ class Map extends egret.Sprite { ...@@ -102,7 +102,8 @@ class Map extends egret.Sprite {
grid.alpha = 1 grid.alpha = 1
}) })
runners.forEach(runner => { runners.forEach(runner => {
if (this.touchArea.hitTestPoint(runner.x, runner.y)) { console.log(this.touchArea.hitTestPoint(runner.x, runner.y), runner)
if (this.touchArea.hitTestPoint(runner.x * gridWidth, runner.y * gridHeight)) {
runner.alpha = 1 runner.alpha = 1
} }
}) })
...@@ -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 => {
alpha = 0 runner.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