Commit 3d3bab4e authored by haiyoucuv's avatar haiyoucuv

init

parent bb09cf0d
......@@ -6,6 +6,8 @@ export abstract class LevelBase extends Base {
abstract level: number;
qs: Sprite;
gameOver: boolean;
onLoad() {
this.qs = this.addChild(new Sprite(Assets.get(`level${this.level}/qs.png`)));
this.qs.anchor.set(0.5);
......
......@@ -6,6 +6,7 @@ import { GameEvent, globalEvent } from "./GameEvent.ts";
import { Level1 } from "@/pages/GamePage/Level/Level1.ts";
import { Level2 } from "@/pages/GamePage/Level/Level2.ts";
import { Level3 } from "@/pages/GamePage/Level/Level3.ts";
import { Level4 } from "@/pages/GamePage/Level/Level4.ts";
@observer
export class Game extends Base {
......@@ -14,7 +15,7 @@ export class Game extends Base {
const qsBg = this.addChild(new Sprite(Assets.get("问题.png")));
qsBg.position.set(49, 316);
this.addChild(new Level3());
this.addChild(new Level4());
globalEvent.on(GameEvent.ReceiveEffect, this.receiveEffect, this);
}
......
import { LevelBase } from "@/pages/GamePage/Components/LevelBase.ts";
import { Assets, Sprite } from "pixi.js";
export class Level4 extends LevelBase {
level: number = 4;
A: Sprite;
B: Sprite;
C: Sprite;
D: Sprite;
right: Sprite;
error: Sprite;
onLoad() {
super.onLoad();
this.A = this.addChild(new Sprite(Assets.get(`level${this.level}/A.png`)));
this.A.position.set(73, 1061);
this.B = this.addChild(new Sprite(Assets.get(`level${this.level}/B.png`)));
this.B.position.set(296, 1061);
this.C = this.addChild(new Sprite(Assets.get(`level${this.level}/C.png`)));
this.C.position.set(519, 1061);
this.D = this.addChild(new Sprite(Assets.get(`level${this.level}/D.png`)));
this.D.position.set(269, 668);
this.right = this.addChild(new Sprite(Assets.get(`level${this.level}/right.png`)));
this.right.position.set(243, 658);
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));
});
}
onTapOption(item: Sprite) {
const isRight = item === this.D;
this.right.visible = isRight;
this.error.visible = !isRight;
const dp = -7;
this.error.position.set(item.x + dp, item.y + dp);
}
}
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