Commit 58926671 authored by haiyoucuv's avatar haiyoucuv

11

parent 4de28ec8
src/assets/Game/level14/right.png

209 KB | W: | H:

src/assets/Game/level14/right.png

207 KB | W: | H:

src/assets/Game/level14/right.png
src/assets/Game/level14/right.png
src/assets/Game/level14/right.png
src/assets/Game/level14/right.png
  • 2-up
  • Swipe
  • Onion skin
...@@ -48,10 +48,10 @@ export class Game extends Base { ...@@ -48,10 +48,10 @@ 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 Level7(this.setPauseCd)); this.level = this.addChild(new Level14(this.setPauseCd));
globalEvent.on(GameEvent.NextLevel, this.nextLevel, this); globalEvent.on(GameEvent.NextLevel, this.nextLevel, this);
this.nextLevel(); // this.nextLevel();
this.startCd(); this.startCd();
} }
......
...@@ -9,6 +9,7 @@ export class Level11 extends LevelBase { ...@@ -9,6 +9,7 @@ export class Level11 extends LevelBase {
level: number = 11; level: number = 11;
A: Sprite; A: Sprite;
B: Sprite;
right: Sprite; right: Sprite;
error: Sprite; error: Sprite;
...@@ -22,14 +23,14 @@ export class Level11 extends LevelBase { ...@@ -22,14 +23,14 @@ export class Level11 extends LevelBase {
onLoad() { onLoad() {
super.onLoad(); super.onLoad();
this.addChild(new Sprite(Assets.get(`level${this.level}/长颈鹿.png`)))
.position.set(91, 765);
this.A = this.addChild(new Sprite(Assets.get(`level${this.level}/冰箱.png`))); this.A = this.addChild(new Sprite(Assets.get(`level${this.level}/冰箱.png`)));
this.A.anchor.set(0.5); this.A.anchor.set(0.5);
this.A.position.set(541, 956); this.A.position.set(541, 956);
this.A.scale.set(0.5746031746031746); this.A.scale.set(0.5746031746031746);
this.B = this.addChild(new Sprite(Assets.get(`level${this.level}/长颈鹿.png`)));
this.B.position.set(91, 765);
this.right = this.addChild(new Sprite(Assets.get(`common/right.png`))); this.right = this.addChild(new Sprite(Assets.get(`common/right.png`)));
this.right.position.set(642, 1141); this.right.position.set(642, 1141);
this.right.alpha = 0; this.right.alpha = 0;
...@@ -40,8 +41,37 @@ export class Level11 extends LevelBase { ...@@ -40,8 +41,37 @@ export class Level11 extends LevelBase {
this.A.on("globalpointermove", this.onPointerMove, this); this.A.on("globalpointermove", this.onPointerMove, this);
this.A.on("pointerup", this.onPointerUp, this); this.A.on("pointerup", this.onPointerUp, this);
this.A.on("pointerupoutside", this.onPointerUp, this); this.A.on("pointerupoutside", this.onPointerUp, this);
this.B.on("pointerdown", this.onBPointerDown, this);
this.B.on("pointerup", this.onBPointerUp, this);
this.B.on("globalpointermove", this.onBPointerMove, this);
}
pos = null;
onBPointerUp(e) {
this.pos = null;
}
onBPointerDown(e) {
const { x, y } = e.data.global;
this.pos = {
x: x - this.B.x,
y: y - this.B.y
}
} }
onBPointerMove(e) {
if (!this.pos) return;
const { x, y } = e.data.global;
const nx = x - this.pos.x;
const ny = y - this.pos.y;
this.B.position.set(nx, ny);
}
onPointerDown(e) { onPointerDown(e) {
console.log("pointerdown", e.pointerId, e.data.global); console.log("pointerdown", e.pointerId, e.data.global);
......
import { LevelBase } from "@/pages/GamePage/Components/LevelBase.ts"; import { LevelBase } from "@/pages/GamePage/Components/LevelBase.ts";
import { Assets, Sprite } from "pixi.js"; import { Assets, Rectangle, Sprite } from "pixi.js";
import { Ease, Tween } from "@/core/tween"; import { Ease, Tween } from "@/core/tween";
import { GameEvent, globalEvent } from "@/pages/GamePage/GameEvent.ts"; import { GameEvent, globalEvent } from "@/pages/GamePage/GameEvent.ts";
import { errorWaitTime, rightWaitTime } from "@/pages/GamePage/Level/LevelConfig.ts"; import { errorWaitTime, rightWaitTime } from "@/pages/GamePage/Level/LevelConfig.ts";
...@@ -44,6 +44,10 @@ export class Level14 extends LevelBase { ...@@ -44,6 +44,10 @@ export class Level14 extends LevelBase {
this.A.on("pointerdown", this.onAPointerDown, this); this.A.on("pointerdown", this.onAPointerDown, this);
this.A.on("pointerup", this.onAPointerUp, this); this.A.on("pointerup", this.onAPointerUp, this);
this.A.on("globalpointermove", this.onAPointerMove, this); this.A.on("globalpointermove", this.onAPointerMove, this);
this.B.on("pointerdown", this.onAPointerDown, this);
this.B.on("pointerup", this.onAPointerUp, this);
this.B.on("globalpointermove", this.onAPointerMove, this);
} }
onTapOption(item: Sprite) { onTapOption(item: Sprite) {
...@@ -69,6 +73,7 @@ export class Level14 extends LevelBase { ...@@ -69,6 +73,7 @@ export class Level14 extends LevelBase {
}); });
} }
target = null;
pos = null; pos = null;
onAPointerUp(e) { onAPointerUp(e) {
...@@ -76,10 +81,11 @@ export class Level14 extends LevelBase { ...@@ -76,10 +81,11 @@ export class Level14 extends LevelBase {
} }
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.A.x, x: x - e.target.x,
y: y - this.A.y y: y - e.target.y
} }
} }
...@@ -88,18 +94,27 @@ export class Level14 extends LevelBase { ...@@ -88,18 +94,27 @@ export class Level14 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.A.position.set(nx, ny); this.target.position.set(nx, ny);
if ( this.check();
nx >= 420 }
&& nx <= 540
&& ny >= 930 check() {
&& ny <= 1120 const { x: ax, y: ay, width: aw, height: ah } = this.A;
) { const { x: bx, y: by, width: bw, height: bh } = this.B;
const aRect = new Rectangle(ax, ay, aw, ah);
const bRect = new Rectangle(bx, by, bw, bh);
if (aRect.intersects(bRect)) {
this.setPauseCd(true); this.setPauseCd(true);
this.setTouchEnable(false); this.setTouchEnable(false);
Tween.get(this.B)
.to({ x: 306, y: 1000 }, 444, Ease.quadInOut)
Tween.get(this.A) Tween.get(this.A)
.to({ x: 484, y: 1040 }, 444, Ease.quadInOut) .to({ x: 292, y: 1040 }, 444, Ease.quadInOut)
.call(() => { .call(() => {
Tween.get(this.right) Tween.get(this.right)
.to({ alpha: 1 }, 444, Ease.quadInOut) .to({ alpha: 1 }, 444, Ease.quadInOut)
...@@ -108,8 +123,8 @@ export class Level14 extends LevelBase { ...@@ -108,8 +123,8 @@ export class Level14 extends LevelBase {
globalEvent.emit(GameEvent.NextLevel); globalEvent.emit(GameEvent.NextLevel);
}); });
}) })
} }
} }
onDestroy() { onDestroy() {
......
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