Commit 2dabd378 authored by haiyoucuv's avatar haiyoucuv

20

parent e430682e
...@@ -15,6 +15,7 @@ import { Level9 } from "@/pages/GamePage/Level/Level9.ts"; ...@@ -15,6 +15,7 @@ import { Level9 } from "@/pages/GamePage/Level/Level9.ts";
import { Level10 } from "@/pages/GamePage/Level/Level10.ts"; import { Level10 } from "@/pages/GamePage/Level/Level10.ts";
import { Level13 } from "@/pages/GamePage/Level/Level13.ts"; import { Level13 } from "@/pages/GamePage/Level/Level13.ts";
import { Level14 } from "@/pages/GamePage/Level/Level14.ts"; import { Level14 } from "@/pages/GamePage/Level/Level14.ts";
import { Level15 } from "@/pages/GamePage/Level/Level15.ts";
import { Level18 } from "@/pages/GamePage/Level/Level18.ts"; import { Level18 } from "@/pages/GamePage/Level/Level18.ts";
import { Level20 } from "@/pages/GamePage/Level/Level20.ts"; import { Level20 } from "@/pages/GamePage/Level/Level20.ts";
import { Level21 } from "@/pages/GamePage/Level/Level21.ts"; import { Level21 } from "@/pages/GamePage/Level/Level21.ts";
...@@ -33,7 +34,7 @@ export class Game extends Base { ...@@ -33,7 +34,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 Level20()); this.level = this.addChild(new Level15());
globalEvent.on(GameEvent.NextLevel, this.nextLevel, this); globalEvent.on(GameEvent.NextLevel, this.nextLevel, this);
// this.nextLevel(); // this.nextLevel();
......
import { LevelBase } from "@/pages/GamePage/Components/LevelBase.ts";
import { Assets, Rectangle, Sprite } from "pixi.js";
import { Ease, Tween } from "@/core/tween";
import { GameEvent, globalEvent } from "@/pages/GamePage/GameEvent.ts";
export class Level15 extends LevelBase {
level: number = 15;
A: Sprite;
B: Sprite;
C: Sprite;
D: Sprite;
mi: Sprite;
mi2: Sprite;
right: Sprite;
error: Sprite;
onLoad() {
super.onLoad();
this.D = this.addChild(new Sprite(Assets.get(`level${this.level}/D.png`)));
this.D.position.set(460, 766);
this.mi = this.addChild(new Sprite(Assets.get(`level${this.level}/mi.png`)));
this.mi.position.set(129, 675);
this.mi2 = this.addChild(new Sprite(Assets.get(`level${this.level}/mi2.png`)));
this.mi2.position.set(129, 719);
const table = this.addChild(new Sprite(Assets.get(`level${this.level}/img.png`)));
table.position.set(0, 665);
table.interactive = false;
table.eventMode = "none";
this.A = this.addChild(new Sprite(Assets.get(`level${this.level}/A.png`)));
this.A.position.set(78, 1169);
this.B = this.addChild(new Sprite(Assets.get(`level${this.level}/B.png`)));
this.B.position.set(311, 1159);
this.C = this.addChild(new Sprite(Assets.get(`level${this.level}/C.png`)));
this.C.position.set(495, 1149);
this.right = this.addChild(new Sprite(Assets.get(`level${this.level}/right.png`)));
this.right.position.set(146, 825);
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.interactive = false;
this.error.eventMode = "none";
[this.D].forEach((item) => {
item.on("pointerdown", this.onAPointerDown, this);
item.on("pointerup", this.onAPointerUp, this);
item.on("globalpointermove", this.onAPointerMove, this);
});
[this.A, this.B, this.C].forEach((item) => {
item.on("pointertap", this.onTapOption.bind(this, item));
});
}
onTapOption(item: Sprite) {
this.setTouchEnable(false);
const dp = 75;
const wait = 2000;
this.error.visible = true;
this.error.position.set(item.x + item.width - 30, item.y + item.height - 50);
Tween.removeTweens(this.error);
Tween.get(this.error)
.wait(wait)
.call(() => {
this.error.visible = false;
this.setTouchEnable(true);
});
}
target: Sprite = null;
pos: { x: number, y: number } = null;
onAPointerUp(e) {
this.pos = null;
this.target = null;
}
onAPointerDown(e) {
this.target = e.target;
const { x, y } = e.data.global;
this.pos = {
x: x - e.target.x,
y: y - e.target.y
}
this.addChild(e.target);
}
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.target.position.set(nx, ny);
this.check();
}
check() {
const { x: ax, y: ay, width: aw, height: ah } = this.target;
const isIns = new Rectangle(ax + 60, ay, aw - 60, ah)
.intersects(new Rectangle(180, 840, 37, 55));
if (isIns) {
this.setTouchEnable(false);
this.target.eventMode = "none";
this.target.interactive = false;
Tween.get(this.D).to({ x: 144, y: 824, width: 93, height: 96 }, 666, Ease.quadInOut);
this.target = null;
this.pos = null;
Tween.get(this.D)
.wait(666)
.to({ alpha: 0 }, 666, Ease.quadInOut);
Tween.get(this.mi)
.wait(666)
.to({ alpha: 0 }, 666, Ease.quadInOut);
Tween.get(this.mi2)
.wait(666)
.to({ alpha: 1 }, 666, Ease.quadInOut);
Tween.get(this.right)
.wait(999)
.to({ alpha: 1 }, 666, Ease.quadInOut)
.wait(2000)
.call(() => {
globalEvent.emit(GameEvent.NextLevel);
});
}
}
onDestroy() {
super.onDestroy();
Tween.removeTweens(this.right);
[this.A, this.B].forEach((item) => {
item.off("globalpointermove", this.onAPointerMove, this);
});
}
}
...@@ -10,6 +10,7 @@ import { Level9 } from "@/pages/GamePage/Level/Level9.ts"; ...@@ -10,6 +10,7 @@ import { Level9 } from "@/pages/GamePage/Level/Level9.ts";
import { Level10 } from "@/pages/GamePage/Level/Level10.ts"; import { Level10 } from "@/pages/GamePage/Level/Level10.ts";
import { Level13 } from "@/pages/GamePage/Level/Level13.ts"; import { Level13 } from "@/pages/GamePage/Level/Level13.ts";
import { Level14 } from "@/pages/GamePage/Level/Level14.ts"; import { Level14 } from "@/pages/GamePage/Level/Level14.ts";
import { Level15 } from "@/pages/GamePage/Level/Level15.ts";
import { Level18 } from "@/pages/GamePage/Level/Level18.ts"; import { Level18 } from "@/pages/GamePage/Level/Level18.ts";
import { Level20 } from "@/pages/GamePage/Level/Level20.ts"; import { Level20 } from "@/pages/GamePage/Level/Level20.ts";
import { Level21 } from "@/pages/GamePage/Level/Level21.ts"; import { Level21 } from "@/pages/GamePage/Level/Level21.ts";
...@@ -32,7 +33,7 @@ export const LevelArr = [ ...@@ -32,7 +33,7 @@ export const LevelArr = [
{ cls: Level9, tip: `掐断烟头` }, // 12 { cls: Level9, tip: `掐断烟头` }, // 12
{ cls: Level13, tip: `打开盖子看看` }, { cls: Level13, tip: `打开盖子看看` },
{ cls: Level14, tip: `将香蕉移动到牛奶中<br/>变成香蕉牛奶` }, { cls: Level14, tip: `将香蕉移动到牛奶中<br/>变成香蕉牛奶` },
{ cls: Level14, tip: `猫吃老鼠` }, // 15 { cls: Level15, tip: `猫吃老鼠` },
{ cls: Level14, tip: `移动笼子罩住小鸭子` }, // 16 { cls: Level14, tip: `移动笼子罩住小鸭子` }, // 16
{ cls: Level14, tip: `别忘了,人是高等动物哦` }, // 17 { cls: Level14, tip: `别忘了,人是高等动物哦` }, // 17
{ cls: Level18, tip: `移开乌云露出太阳<br/>让冰块融化` }, { cls: Level18, tip: `移开乌云露出太阳<br/>让冰块融化` },
......
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