Commit 93be376a by Shawn Wang

Merge branch 'develop' of cd.i.strikingly.com:shawn.wang/crazyflirt into develop

parents 21281ef2 ad398fb5
......@@ -33,10 +33,10 @@ class Map extends egret.Sprite {
this.addChild(this.touchArea)
Store.getState().runners.forEach(runnerData => {
const runner = new Runner(runnerData)
this.addChild(runner)
if (Store.isCatcher()) {
runner.alpha === 0
runner.alpha = 0
}
this.addChild(runner)
this.runnerMap[runnerData.t_cid] = runner
})
EventBus.addEventListener('moving', (payload) => {
......@@ -81,8 +81,9 @@ class Map extends egret.Sprite {
public getCatchedRunners(x, y) {
const catchedRunners = []
Store.getState().runners.forEach(runner => {
if (runner.x === x && runner.y === y) {
catchedRunners.push(runner)
const updatedRunner = this.runnerMap[runner.t_cid]
if (updatedRunner.x === x && updatedRunner.y === y) {
catchedRunners.push(updatedRunner)
}
})
return catchedRunners
......@@ -102,11 +103,11 @@ class Map extends egret.Sprite {
grid.alpha = 1
})
runners.forEach(runner => {
if (this.touchArea.hitTestPoint(runner.x, runner.y)) {
runner.alpha = 1
if (this.touchArea.hitTestPoint(runner.x * gridWidth, runner.y * gridHeight)) {
this.runnerMap[runner.t_cid].alpha = 1
}
})
this.getCatchedRunners().forEach(runner => {
this.getCatchedRunners(x, y).forEach(runner => {
platform.sendSocketMessage({
data: JSON.stringify({
type: 'catch',
......@@ -114,8 +115,8 @@ class Map extends egret.Sprite {
cid: Store.getState().cid,
payload: {
mark: runner.mark,
x,
y,
x: x / gridWidth,
y: y / gridHeight,
t_cid: runner.t_cid
}
}),
......@@ -130,7 +131,7 @@ class Map extends egret.Sprite {
grid.alpha = 0
})
runners.forEach(runner => {
alpha = 0
this.runnerMap[runner.t_cid].alpha = 0
})
this.touchArea.alpha = 0
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