Commit 9aef914c authored by haiyoucuv's avatar haiyoucuv

11

parent 9fbd475c
......@@ -48,10 +48,10 @@ export class Game extends Base {
const qsBg = this.addChild(new Sprite(Assets.get("问题.png")));
qsBg.position.set(49, 316);
// this.level = this.addChild(new Level14(this.setPauseCd));
this.level = this.addChild(new Level19(this.setPauseCd));
globalEvent.on(GameEvent.NextLevel, this.nextLevel, this);
this.nextLevel();
// this.nextLevel();
this.startCd();
}
......
......@@ -169,5 +169,8 @@ export class Level11 extends LevelBase {
this.A.off("globalpointermove", this.onPointerMove, this);
this.A.off("pointerup", this.onPointerUp, this);
this.A.off("pointerupoutside", this.onPointerUp, this);
this.B.off("pointerdown", this.onPointerDown, this);
this.B.off("globalpointermove", this.onPointerMove, this);
this.B.off("pointerup", this.onPointerUp, this);
}
}
......@@ -8,6 +8,9 @@ export class Level19 extends LevelBase {
level: number = 19;
p1: Sprite;
p2: Sprite;
A: Sprite;
right: Sprite;
......@@ -30,6 +33,11 @@ export class Level19 extends LevelBase {
this.A.position.set(430, 1100);
this.A.scale.set(0.5948827292110874);
this.p1 = this.addChild(new Sprite(Assets.get(`level${this.level}/女.png`)));
this.p1.position.set(32, 897);
this.p2 = this.addChild(new Sprite(Assets.get(`level${this.level}/男.png`)));
this.p2.position.set(176, 878);
this.right = this.addChild(new Sprite(Assets.get(`common/right.png`)));
this.right.position.set(613, 1104);
this.right.alpha = 0;
......@@ -40,6 +48,38 @@ export class Level19 extends LevelBase {
this.A.on("globalpointermove", this.onPointerMove, this);
this.A.on("pointerup", this.onPointerUp, this);
this.A.on("pointerupoutside", this.onPointerUp, this);
[this.p1, this.p2]
.forEach((item) => {
item.on("pointerdown", this.onPPointerDown, this);
item.on("globalpointermove", this.onPPointerMove, this);
item.on("pointerup", this.onPPointerUp, this);
item.on("pointerupoutside", this.onPPointerUp, this);
});
}
target = null;
pos = null;
onPPointerUp(e) {
this.pos = null;
}
onPPointerDown(e) {
this.target = e.target;
const { x, y } = e.data.global;
this.pos = {
x: x - e.target.x,
y: y - e.target.y
}
}
onPPointerMove(e) {
if (!this.pos) return;
const { x, y } = e.data.global;
const nx = x - this.pos.x;
const ny = y - this.pos.y;
this.target.position.set(nx, ny);
}
onPointerDown(e) {
......
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