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 { ...@@ -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) => {
...@@ -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
...@@ -102,11 +103,11 @@ class Map extends egret.Sprite { ...@@ -102,11 +103,11 @@ 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)) { if (this.touchArea.hitTestPoint(runner.x * gridWidth, runner.y * gridHeight)) {
runner.alpha = 1 this.runnerMap[runner.t_cid].alpha = 1
} }
}) })
this.getCatchedRunners().forEach(runner => { this.getCatchedRunners(x, y).forEach(runner => {
platform.sendSocketMessage({ platform.sendSocketMessage({
data: JSON.stringify({ data: JSON.stringify({
type: 'catch', type: 'catch',
...@@ -114,8 +115,8 @@ class Map extends egret.Sprite { ...@@ -114,8 +115,8 @@ class Map extends egret.Sprite {
cid: Store.getState().cid, cid: Store.getState().cid,
payload: { payload: {
mark: runner.mark, mark: runner.mark,
x, x: x / gridWidth,
y, y: y / gridHeight,
t_cid: runner.t_cid t_cid: runner.t_cid
} }
}), }),
...@@ -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 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