Commit d036a9bd authored by haiyoucuv's avatar haiyoucuv

init

parent 796c5372
...@@ -7,6 +7,7 @@ import { Level1 } from "@/pages/GamePage/Level/Level1.ts"; ...@@ -7,6 +7,7 @@ import { Level1 } from "@/pages/GamePage/Level/Level1.ts";
import { Level2 } from "@/pages/GamePage/Level/Level2.ts"; import { Level2 } from "@/pages/GamePage/Level/Level2.ts";
import { Level3 } from "@/pages/GamePage/Level/Level3.ts"; import { Level3 } from "@/pages/GamePage/Level/Level3.ts";
import { Level4 } from "@/pages/GamePage/Level/Level4.ts"; import { Level4 } from "@/pages/GamePage/Level/Level4.ts";
import { Level5 } from "@/pages/GamePage/Level/Level5.ts";
import { Level8 } from "@/pages/GamePage/Level/Level8.ts"; import { Level8 } from "@/pages/GamePage/Level/Level8.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";
...@@ -23,7 +24,7 @@ export class Game extends Base { ...@@ -23,7 +24,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 Level7()); this.level = this.addChild(new Level5());
gameStore.start(); gameStore.start();
......
import { LevelBase } from "@/pages/GamePage/Components/LevelBase.ts";
import { Assets, Sprite } from "pixi.js";
import { Tween } from "@/core/tween";
import { GameEvent, globalEvent } from "@/pages/GamePage/GameEvent.ts";
export class Level5 extends LevelBase {
level: number = 5;
A: Sprite;
B: Sprite;
C: Sprite;
D: Sprite;
right: Sprite;
error: Sprite;
onLoad() {
super.onLoad();
this.B = this.addChild(new Sprite(Assets.get(`level${this.level}/B.png`)));
this.B.position.set(447, 669);
this.C = this.addChild(new Sprite(Assets.get(`level${this.level}/C.png`)));
this.C.position.set(143, 999);
this.D = this.addChild(new Sprite(Assets.get(`level${this.level}/D.png`)));
this.D.position.set(377, 999);
this.A = this.addChild(new Sprite(Assets.get(`level${this.level}/A.png`)));
this.A.position.set(201, 775);
this.right = this.addChild(new Sprite(Assets.get(`level${this.level}/right.png`)));
this.right.position.set(371, 993)
this.right.visible = false;
this.right.interactive = false;
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, this.C, this.D]
.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: 70, y: 70 }],
[this.B, { x: 120, y: 190 }],
[this.C, { x: 10, y: 140 }],
[this.D, { x: 150, y: 150 }],
]).get(item);
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);
}
onDestroy() {
super.onDestroy();
Tween.removeTweens(this.error);
Tween.removeTweens(this.right);
}
}
...@@ -2,6 +2,7 @@ import { Level1 } from "@/pages/GamePage/Level/Level1.ts"; ...@@ -2,6 +2,7 @@ import { Level1 } from "@/pages/GamePage/Level/Level1.ts";
import { Level2 } from "@/pages/GamePage/Level/Level2.ts"; import { Level2 } from "@/pages/GamePage/Level/Level2.ts";
import { Level3 } from "@/pages/GamePage/Level/Level3.ts"; import { Level3 } from "@/pages/GamePage/Level/Level3.ts";
import { Level4 } from "@/pages/GamePage/Level/Level4.ts"; import { Level4 } from "@/pages/GamePage/Level/Level4.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 { Level23 } from "@/pages/GamePage/Level/Level23.ts"; import { Level23 } from "@/pages/GamePage/Level/Level23.ts";
...@@ -12,6 +13,7 @@ export const LevelArr = [ ...@@ -12,6 +13,7 @@ export const LevelArr = [
Level2, Level2,
Level3, Level3,
Level4, Level4,
Level5,
Level7, Level7,
Level8, Level8,
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