Commit de3bcbb0 by Matt

fix hit test

parent 942afd4d
...@@ -96,27 +96,31 @@ class Map extends egret.Sprite { ...@@ -96,27 +96,31 @@ class Map extends egret.Sprite {
centerGrid.bg.texture = RES.getRes('grid_select_jpg') centerGrid.bg.texture = RES.getRes('grid_select_jpg')
const runners = Store.getState().runners const runners = Store.getState().runners
this.touchArea.alpha = 1 // this.touchArea.alpha = 1
this.touchArea.x = x - 2 * gridWidth this.touchArea.x = x - 2 * gridWidth
this.touchArea.y = y - 2 * gridHeight this.touchArea.y = y - 2 * gridHeight
// surroundedGrids.forEach(grid => {
// grid.alpha = 1
// })
const twTouchArea = egret.Tween.get( this.touchArea );
twTouchArea.to( {alpha: 1}, 300 ).call(function() {
surroundedGrids.forEach(grid => { surroundedGrids.forEach(grid => {
grid.alpha = 1 grid.alpha = 1
}) })
// const twTouchArea = egret.Tween.get( this.touchArea ); // egret.Tween.get(grid).to({ alpha: 1 }, 300)
// twTouchArea.to( {alpha: 1}, 300 ).call(function() { })
// })
// surroundedGrids.forEach(grid => { // surroundedGrids.forEach(grid => {
// egret.Tween.get(grid).to({ alpha: 1 }, 300) // egret.Tween.get(grid).to({ alpha: 1 }, 300)
// }) // })
runners.forEach(runner => { runners.forEach(runner => {
console.log(runner.x, runner.y, this.touchArea.hitTestPoint(runner.x * gridWidth, runner.y * gridHeight)) console.log(runner.x, runner.y, this.touchArea.hitTestPoint(runner.x * gridWidth, runner.y * gridHeight))
const runnerInMap = this.runnerMap[runner.t_cid] const runnerInMap = this.runnerMap[runner.t_cid]
if (this.touchArea.hitTestPoint(runnerInMap.x * gridWidth, runnerInMap.y * gridHeight)) { if (this.touchArea.hitTestPoint(runnerInMap.x, runnerInMap.y)) {
runnerInMap.alpha = 1 runnerInMap.alpha = 1
} }
}) })
this.getCatchedRunners(x, y).forEach(runner => { this.getCatchedRunners(x, y).forEach(runner => {
platform.sendSocketMessage({ platform.sendSocketMessage({
data: JSON.stringify({ data: JSON.stringify({
type: 'catch', type: 'catch',
...@@ -133,6 +137,10 @@ class Map extends egret.Sprite { ...@@ -133,6 +137,10 @@ class Map extends egret.Sprite {
if (Store.isMe(runner.t_cid) || Store.isCatcher()) { if (Store.isMe(runner.t_cid) || Store.isCatcher()) {
SoundManager.getInstance().playCatched() SoundManager.getInstance().playCatched()
} }
if (Store.isCatcher()) {
this.runnerMap[runner.t_cid].alpha = 0
}
}) })
setTimeout(() => { setTimeout(() => {
centerGrid.bg.texture = RES.getRes('grid_jpg') centerGrid.bg.texture = RES.getRes('grid_jpg')
......
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