Commit 6f5ab090 authored by cc's avatar cc
parents 7000fd7e f0c67089
...@@ -10,6 +10,8 @@ import { Level4 } from "@/pages/GamePage/Level/Level4.ts"; ...@@ -10,6 +10,8 @@ import { Level4 } from "@/pages/GamePage/Level/Level4.ts";
import { Level5 } from "@/pages/GamePage/Level/Level5.ts"; import { Level5 } from "@/pages/GamePage/Level/Level5.ts";
import { Level7 } from "@/pages/GamePage/Level/Level7.ts"; import { Level7 } from "@/pages/GamePage/Level/Level7.ts";
import { Level8 } from "@/pages/GamePage/Level/Level8.ts"; import { Level8 } from "@/pages/GamePage/Level/Level8.ts";
import { Level9 } from "@/pages/GamePage/Level/Level9.ts";
import { Level14 } from "@/pages/GamePage/Level/Level14.ts";
import { Level23 } from "@/pages/GamePage/Level/Level23.ts"; import { Level23 } from "@/pages/GamePage/Level/Level23.ts";
import gameStore from "@/store/gameStore.ts"; import gameStore from "@/store/gameStore.ts";
import { LevelArr } from "@/pages/GamePage/Level/LevelConfig.ts"; import { LevelArr } from "@/pages/GamePage/Level/LevelConfig.ts";
...@@ -24,7 +26,7 @@ export class Game extends Base { ...@@ -24,7 +26,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 Level5()); this.level = this.addChild(new Level9());
gameStore.start(); gameStore.start();
......
import { LevelBase } from "@/pages/GamePage/Components/LevelBase.ts";
import { Assets, Sprite } from "pixi.js";
import { Ease, Tween } from "@/core/tween";
import { GameEvent, globalEvent } from "@/pages/GamePage/GameEvent.ts";
export class Level14 extends LevelBase {
level: number = 14;
A: Sprite;
B: Sprite;
right: Sprite;
error: Sprite;
onLoad() {
super.onLoad();
this.addChild(new Sprite(Assets.get(`level${this.level}/img.png`)))
.position.set(208, 656);
this.B = this.addChild(new Sprite(Assets.get(`level${this.level}/B.png`)));
this.B.position.set(510, 1007);
this.A = this.addChild(new Sprite(Assets.get(`level${this.level}/A.png`)));
this.A.position.set(117, 1035);
this.right = this.addChild(new Sprite(Assets.get(`level${this.level}/right.png`)));
this.right.position.set(208, 656);
this.right.alpha = 0;
this.right.interactive = false;
this.right.eventMode = "none";
this.error = this.addChild(new Sprite(Assets.get(`level${this.level}/error.png`)));
this.error.visible = false;
this.error.interactive = false;
[this.A, this.B]
.forEach((item) => {
item.on("pointertap", this.onTapOption.bind(this, item));
});
this.A.on("pointerdown", this.onAPointerDown, this);
this.A.on("globalpointermove", this.onAPointerMove, this);
}
onTapOption(item: Sprite) {
this.pos = null;
this.setTouchEnable(false);
const dp = new Map([
[this.A, { x: 110, y: 120 }],
[this.B, { x: 100, y: 150 }],
]).get(item);
console.log(dp)
this.error.position.set(item.x + dp.x, item.y + dp.y);
this.error.visible = true;
Tween.removeTweens(this.error);
Tween.get(this.error)
.wait(2000)
.call(() => {
this.error.visible = false;
this.setTouchEnable(true);
});
}
pos = null;
onAPointerDown(e) {
const { x, y } = e.data.global;
this.pos = {
x: x - this.A.x,
y: y - this.A.y
}
}
onAPointerMove(e) {
if (!this.pos) return;
const { x, y } = e.data.global;
const nx = x - this.pos.x;
const ny = y - this.pos.y;
this.A.position.set(nx, ny);
if (
nx >= 420
&& nx <= 540
&& ny >= 930
&& ny <= 1120
) {
this.setTouchEnable(false);
Tween.get(this.A)
.to({ x: 484, y: 1040 }, 444, Ease.quadInOut)
.call(() => {
Tween.get(this.right)
.to({ alpha: 1 }, 444, Ease.quadInOut)
.wait(2000)
.call(() => {
globalEvent.emit(GameEvent.NextLevel);
});
})
}
}
onDestroy() {
super.onDestroy();
Tween.removeTweens(this.A);
Tween.removeTweens(this.error);
Tween.removeTweens(this.right);
this.A.off("globalpointermove", this.onAPointerMove, this);
}
}
import { LevelBase } from "@/pages/GamePage/Components/LevelBase.ts";
import { Assets, Sprite } from "pixi.js";
import { Ease, Tween } from "@/core/tween";
import { GameEvent, globalEvent } from "@/pages/GamePage/GameEvent.ts";
export class Level9 extends LevelBase {
level: number = 9;
A: Sprite;
right: Sprite;
error: Sprite;
onLoad() {
super.onLoad();
this.addChild(new Sprite(Assets.get(`level${this.level}/img.png`)))
.position.set(46, 979);
this.A = this.addChild(new Sprite(Assets.get(`level${this.level}/duck.png`)));
this.A.position.set(330, 764);
this.right = this.addChild(new Sprite(Assets.get(`level${this.level}/right.png`)));
this.right.position.set(470, 1050);
this.right.alpha = 0;
this.right.interactive = false;
this.right.eventMode = "none";
this.A.on("pointerdown", this.onAPointerDown, this);
this.A.on("globalpointermove", this.onAPointerMove, this);
}
pos = null;
onAPointerDown(e) {
const { x, y } = e.data.global;
this.pos = {
x: x - this.A.x,
y: y - this.A.y
}
}
onAPointerMove(e) {
if (!this.pos) return;
const { x, y } = e.data.global;
const nx = x - this.pos.x;
const ny = y - this.pos.y;
this.A.position.set(nx, ny);
if (
nx >= 110
&& nx <= 530
&& ny >= 980
&& ny <= 1100
) {
this.setTouchEnable(false);
Tween.get(this.A)
.to({ x: 380, y: 975 }, 444, Ease.quadInOut)
.call(() => {
Tween.get(this.right)
.to({ alpha: 1 }, 444, Ease.quadInOut)
.wait(2000)
.call(() => {
globalEvent.emit(GameEvent.NextLevel);
});
})
}
}
onDestroy() {
super.onDestroy();
Tween.removeTweens(this.A);
Tween.removeTweens(this.right);
this.A.off("globalpointermove", this.onAPointerMove, this);
}
}
...@@ -5,6 +5,8 @@ import { Level4 } from "@/pages/GamePage/Level/Level4.ts"; ...@@ -5,6 +5,8 @@ import { Level4 } from "@/pages/GamePage/Level/Level4.ts";
import { Level5 } from "@/pages/GamePage/Level/Level5.ts"; import { Level5 } from "@/pages/GamePage/Level/Level5.ts";
import { Level7 } from "@/pages/GamePage/Level/Level7.ts"; import { Level7 } from "@/pages/GamePage/Level/Level7.ts";
import { Level8 } from "@/pages/GamePage/Level/Level8.ts"; import { Level8 } from "@/pages/GamePage/Level/Level8.ts";
import { Level9 } from "@/pages/GamePage/Level/Level9.ts";
import { Level14 } from "@/pages/GamePage/Level/Level14.ts";
import { Level23 } from "@/pages/GamePage/Level/Level23.ts"; import { Level23 } from "@/pages/GamePage/Level/Level23.ts";
...@@ -16,5 +18,7 @@ export const LevelArr = [ ...@@ -16,5 +18,7 @@ export const LevelArr = [
Level5, Level5,
Level7, Level7,
Level8, Level8,
Level9,
Level14,
Level23, Level23,
]; ];
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