Browse Source
- init: 仅注册默认导出的场景类;简化 glob 加载逻辑 - SceneManager: 移除 changeStage 别名,保留 changeScene - page_init / welcome2 / 0global: 对齐新场景与 API 调用 Made-with: Cursormaster
5 changed files with 129 additions and 60 deletions
@ -1,46 +1,45 @@ |
|||
import { Button } from "@/components/Button"; |
|||
import { EP } from "@/enums"; |
|||
import { defineWindow } from "@/Game"; |
|||
import Position from "@/Game/Position"; |
|||
import { PWindow } from "@/Game/type"; |
|||
import { Assets } from "pixi.js"; |
|||
import Button from "@/components/Button"; |
|||
import { SceneType } from "@/enums/SceneType"; |
|||
import position from "@/utils/Position"; |
|||
import { BaseScene } from "@/scene/BaseScene"; |
|||
import { Assets, Container, Texture } from "pixi.js"; |
|||
|
|||
export default defineWindow( |
|||
class extends PWindow { |
|||
btn: Button; |
|||
async loadBundle() { |
|||
console.log(this.stage); |
|||
console.log("加载资源"); |
|||
Assets.add({ alias: 'btn-bgaa', src: '/assets/images/button_square_depth_gloss.png' }) |
|||
Assets.add({ alias: 'btn-bg-pressaa', src: '/assets/images/button_square_depth_gradient.png' }) |
|||
const aa = await Assets.load('btn-bgaa') |
|||
console.log(aa); |
|||
export default class Global extends BaseScene { |
|||
stage: Container = new Container(); |
|||
btn?: Button; |
|||
|
|||
constructor() { |
|||
super("0global", SceneType.Resident); |
|||
} |
|||
async layout() { |
|||
this.stage.zIndex = 9999 |
|||
this.btn = new Button({ |
|||
text: "全局", |
|||
bg: await Assets.load('btn-bgaa'), |
|||
pressBg: await Assets.load("btn-bg-pressaa"), |
|||
position: () => Position.get("center", "center", { y: 100, x: 0 }), |
|||
onClick: () => { |
|||
console.log("Button clicked"); |
|||
|
|||
async loadBundle(): Promise<void> { |
|||
Assets.add({ alias: "btn-bga", src: "/assets/images/button_square_depth_gloss.png" }); |
|||
Assets.add({ alias: "btn-bg-press", src: "/assets/images/button_square_depth_gradient.png" }); |
|||
await Assets.load("btn-bga"); |
|||
await Assets.load("btn-bg-press"); |
|||
} |
|||
}) |
|||
this.stage.addChild(this.btn.getView()) |
|||
|
|||
async layout(): Promise<void> { |
|||
this.stage.sortableChildren = true; |
|||
this.stage.zIndex = 9999; |
|||
// const btnBg = Assets.get<Texture>("btn-bga");
|
|||
// const btnBgPress = Assets.get<Texture>("btn-bg-press");
|
|||
// this.btn = new Button({
|
|||
// text: "全局",
|
|||
// bg: btnBg,
|
|||
// pressBg: btnBgPress,
|
|||
// position: () => position.get("center", "center", { y: 100, x: 0 }),
|
|||
// onClick: () => {
|
|||
// console.log("Button clicked");
|
|||
// },
|
|||
// });
|
|||
// this.stage.addChild(this.btn.getView());
|
|||
} |
|||
onLoad() { |
|||
|
|||
onLoad(): void { |
|||
console.log("global page loaded"); |
|||
} |
|||
hide() { |
|||
// this.btn._comp.visible = false
|
|||
} |
|||
show() { |
|||
// this.btn._comp.visible = true
|
|||
} |
|||
onUnLoad() { |
|||
|
|||
onUnLoad(): void { |
|||
} |
|||
}, |
|||
EP.Resident |
|||
); |
|||
} |
|||
|
|||
Loading…
Reference in new issue