Commit ec595bee authored by haiyoucuv's avatar haiyoucuv

20

parent 7d8dd9a9
...@@ -34,7 +34,7 @@ export class Game extends Base { ...@@ -34,7 +34,7 @@ export class Game extends Base {
const qsBg = this.addChild(new Sprite(Assets.get("问题.png"))); const qsBg = this.addChild(new Sprite(Assets.get("问题.png")));
qsBg.position.set(49, 316); qsBg.position.set(49, 316);
this.level = this.addChild(new Level15()); this.level = this.addChild(new Level13());
globalEvent.on(GameEvent.NextLevel, this.nextLevel, this); globalEvent.on(GameEvent.NextLevel, this.nextLevel, this);
// this.nextLevel(); // this.nextLevel();
......
...@@ -20,12 +20,12 @@ export class Level13 extends LevelBase { ...@@ -20,12 +20,12 @@ export class Level13 extends LevelBase {
this.addChild(new Sprite(Assets.get(`level${this.level}/D.png`))) this.addChild(new Sprite(Assets.get(`level${this.level}/D.png`)))
.position.set(198, 687); .position.set(198, 687);
this.B = this.addChild(new Sprite(Assets.get(`level${this.level}/B.png`)));
this.B.position.set(463, 1086);
this.C = this.addChild(new Sprite(Assets.get(`level${this.level}/C.png`))); this.C = this.addChild(new Sprite(Assets.get(`level${this.level}/C.png`)));
this.C.position.set(198, 687); this.C.position.set(198, 687);
this.B = this.addChild(new Sprite(Assets.get(`level${this.level}/B.png`)));
this.B.position.set(463, 1086);
this.A = this.addChild(new Sprite(Assets.get(`level${this.level}/A.png`))); this.A = this.addChild(new Sprite(Assets.get(`level${this.level}/A.png`)));
this.A.position.set(161, 1086); this.A.position.set(161, 1086);
...@@ -35,22 +35,28 @@ export class Level13 extends LevelBase { ...@@ -35,22 +35,28 @@ export class Level13 extends LevelBase {
this.right.interactive = false; this.right.interactive = false;
this.right.eventMode = "none"; this.right.eventMode = "none";
this.C.on("pointerdown", this.onAPointerDown, this); [this.A, this.B, this.C].forEach((item) => {
this.C.on("pointerup", this.onAPointerUp, this); item.on("pointerdown", this.onAPointerDown, this);
this.C.on("globalpointermove", this.onAPointerMove, this); item.on("pointerup", this.onAPointerUp, this);
item.on("globalpointermove", this.onAPointerMove, this);
});
} }
pos = null; target: Sprite = null;
pos: { x: number, y: number } = null;
onAPointerUp(e) { onAPointerUp(e) {
this.pos = null; this.pos = null;
this.target = null;
} }
onAPointerDown(e) { onAPointerDown(e) {
this.target = e.target;
const { x, y } = e.data.global; const { x, y } = e.data.global;
this.pos = { this.pos = {
x: x - this.C.x, x: x - e.target.x,
y: y - this.C.y y: y - e.target.y
} }
} }
...@@ -59,11 +65,13 @@ export class Level13 extends LevelBase { ...@@ -59,11 +65,13 @@ export class Level13 extends LevelBase {
const { x, y } = e.data.global; const { x, y } = e.data.global;
const nx = x - this.pos.x; const nx = x - this.pos.x;
const ny = y - this.pos.y; const ny = y - this.pos.y;
this.C.position.set(nx, ny); this.target.position.set(nx, ny);
const { x: cx, y: cy } = this.C;
if ( if (
nx < 10 || nx > 410 cx < 10 || cx > 410
|| ny < 480 || ny > 900 || cy < 480 || cy > 900
) { ) {
this.setTouchEnable(false); this.setTouchEnable(false);
Tween.get(this.right) Tween.get(this.right)
......
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