|
|
@ -2,7 +2,7 @@ import Button from "@/components/Button"; |
|
|
|
import { gameManager, defineWindow, stageManager } from "@/Game"; |
|
|
|
import Position from "@/Game/Position"; |
|
|
|
import Sound from "@/Game/Sound"; |
|
|
|
import { Container, Sprite, Text, NineSlicePlane, Texture } from "pixi.js"; |
|
|
|
import { Container, Sprite, Text, NineSlicePlane, Texture, AnimatedSprite, Rectangle, utils } from "pixi.js"; |
|
|
|
|
|
|
|
// defineLoadResource([
|
|
|
|
// { name: "my-sound", url: "/bg.mp3", callback: (e) => addSound(e) },
|
|
|
@ -13,10 +13,15 @@ export default defineWindow( |
|
|
|
class { |
|
|
|
stage: Container = null; |
|
|
|
title: Text; // 标题
|
|
|
|
pixie: AnimatedSprite; // 标题
|
|
|
|
bindStage(stage: Container) { |
|
|
|
this.stage = stage; |
|
|
|
} |
|
|
|
layout() { |
|
|
|
const bg = new Sprite(Texture.from("bg")); |
|
|
|
bg.width = gameManager.getInfo().width |
|
|
|
bg.height = gameManager.getInfo().height |
|
|
|
this.stage.addChild(bg) |
|
|
|
this.title = new Text("时间魔法", { |
|
|
|
fontSize: 80, |
|
|
|
fill: "red", |
|
|
@ -34,21 +39,49 @@ export default defineWindow( |
|
|
|
|
|
|
|
const btn = Button({ |
|
|
|
text: "开始游戏", |
|
|
|
position: Position.get("center", "center", { y: 200, x: 0 }), |
|
|
|
bg: "btn-bg", |
|
|
|
pressBg: "btn-bg-press", |
|
|
|
click: () => { |
|
|
|
// Sound.play("my-sound")
|
|
|
|
Sound.play("my-sound") |
|
|
|
// new gameManager.tween.Tween(btn.position).interpolation(gameManager.tween.Interpolation.Bezier)
|
|
|
|
// .to({ alpha: .2, x: btn.width / 2, y: btn.height / 2 }, 1300)
|
|
|
|
// .onComplete(() => {
|
|
|
|
stageManager.changeStage("welcome", { isHolderLast: true }) |
|
|
|
// stageManager.changeStage("welcome", { isHolderLast: true })
|
|
|
|
//播放动画精灵
|
|
|
|
this.pixie.gotoAndPlay(0); |
|
|
|
// })
|
|
|
|
// .start()
|
|
|
|
}, |
|
|
|
}); |
|
|
|
btn.position = Position.get("center", "center", { y: 200, x: 0 }) |
|
|
|
this.stage.addChild(btn); |
|
|
|
console.log(this.stage); |
|
|
|
|
|
|
|
let TextureCache = utils.TextureCache; |
|
|
|
let base = TextureCache["dnf"]; |
|
|
|
//第一个纹理
|
|
|
|
let texture0 = new Texture(base as any) |
|
|
|
texture0.frame = new Rectangle(0, 0, 80, 143); |
|
|
|
//第二个纹理
|
|
|
|
let texture1 = new Texture(base as any) |
|
|
|
texture1.frame = new Rectangle(80, 0, 80, 143); |
|
|
|
//第三个纹理
|
|
|
|
let texture2 = new Texture(base as any) |
|
|
|
texture2.frame = new Rectangle(160, 0, 80, 143); |
|
|
|
//第四个纹理
|
|
|
|
let texture3 = new Texture(base as any) |
|
|
|
texture3.frame = new Rectangle(240, 0, 80, 143); |
|
|
|
|
|
|
|
//创建纹理数组
|
|
|
|
let textures = [texture0, texture1, texture2, texture3]; |
|
|
|
|
|
|
|
//创建动画精灵
|
|
|
|
this.pixie = new AnimatedSprite(textures, false); |
|
|
|
//设置动画精灵的速度
|
|
|
|
this.pixie.animationSpeed = 0.1; |
|
|
|
this.pixie.loop = true; |
|
|
|
this.stage.addChild(this.pixie) |
|
|
|
this.pixie.y = 200 |
|
|
|
} |
|
|
|
onLoad() { |
|
|
|
console.log("onLoad init"); |
|
|
@ -60,6 +93,7 @@ export default defineWindow( |
|
|
|
} |
|
|
|
|
|
|
|
update(dt: number) { |
|
|
|
this.pixie.update(dt) |
|
|
|
this.title.rotation -= 0.01 * dt; |
|
|
|
} |
|
|
|
|
|
|
|