Browse Source

refactor: migrate example scene to new architecture

master
npmrun 3 weeks ago
parent
commit
c042f70d5d
  1. 64
      src/stages/welcome/page_welcome.ts

64
src/stages/welcome/page_welcome.ts

@ -1,45 +1,35 @@
import Button from "@/components/Button";
import { gameManager, defineWindow, stageManager } from "@/Game";
import Sound from "@/Game/Sound";
import { Container, Graphics, Text } from "pixi.js";
import soundManager from "@/utils/Sound";
import { Container } from "pixi.js";
import { BaseScene } from "@/scene/BaseScene";
import { SceneType } from "@/enums/SceneType";
import position from "@/utils/Position";
import Circle from "./circle"
import { PWindow } from "@/Game/type";
import Position from "@/Game/Position";
export default class WelcomeScene extends BaseScene {
stage: Container = new Container();
constructor() {
super("welcome", SceneType.Normal);
}
export default defineWindow("welcome", class extends PWindow {
stage: Container = null
text: any
layout() {
const circle = Circle.render()
this.stage.addChild(circle)
circle.on("touchend", () => {
this.changeStage("welcome2")
})
circle.on("mousedown", () => {
this.changeStage("welcome2")
})
// this.text = new Text({text: "修仙人生日常"})
// this.stage.addChild(this.text)
async layout(): Promise<void> {
const btn = new Button({
text: "修仙人生日常", position: () => Position.get("center", "center"), click: () => {
this.changeStage("init")
}
})
this.stage.addChild(btn._comp)
}
onLoad() {
console.log("onLoad 1");
text: "进入游戏",
onClick: () => {
this.changeScene("welcome2");
},
position: () => position.center(),
});
this.stage.addChild(btn.container);
}
onUnLoad() {
Sound.stop("my-sound")
console.log("onUnLoad 1");
onLoad(): void {
console.log("welcome onLoad");
}
update() {
// this.text.x = gameManager.getInfo().width-this.text.width
// this.text.y = gameManager.getInfo().height-this.text.height
// console.log(22);
onUnLoad(): void {
soundManager.stop("my-sound");
console.log("welcome onUnLoad");
}
})
}
Loading…
Cancel
Save