Compare commits
3 Commits
Author | SHA1 | Date |
---|---|---|
|
a2977d615d | 9 months ago |
|
ca7a2ef217 | 9 months ago |
|
3ea07e4173 | 9 months ago |
After Width: | Height: | Size: 422 B |
After Width: | Height: | Size: 378 B |
After Width: | Height: | Size: 391 B |
After Width: | Height: | Size: 302 B |
After Width: | Height: | Size: 414 B |
After Width: | Height: | Size: 332 B |
After Width: | Height: | Size: 402 B |
After Width: | Height: | Size: 399 B |
After Width: | Height: | Size: 566 B |
After Width: | Height: | Size: 459 B |
After Width: | Height: | Size: 511 B |
After Width: | Height: | Size: 404 B |
After Width: | Height: | Size: 530 B |
After Width: | Height: | Size: 424 B |
After Width: | Height: | Size: 562 B |
After Width: | Height: | Size: 483 B |
After Width: | Height: | Size: 338 B |
After Width: | Height: | Size: 412 B |
After Width: | Height: | Size: 383 B |
After Width: | Height: | Size: 373 B |
After Width: | Height: | Size: 642 B |
After Width: | Height: | Size: 411 B |
After Width: | Height: | Size: 315 B |
After Width: | Height: | Size: 306 B |
After Width: | Height: | Size: 590 B |
After Width: | Height: | Size: 338 B |
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 1023 B |
After Width: | Height: | Size: 958 B |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 306 B |
After Width: | Height: | Size: 375 B |
After Width: | Height: | Size: 355 B |
After Width: | Height: | Size: 337 B |
After Width: | Height: | Size: 615 B |
After Width: | Height: | Size: 374 B |
After Width: | Height: | Size: 286 B |
After Width: | Height: | Size: 268 B |
After Width: | Height: | Size: 532 B |
After Width: | Height: | Size: 304 B |
After Width: | Height: | Size: 579 B |
After Width: | Height: | Size: 579 B |
After Width: | Height: | Size: 774 B |
After Width: | Height: | Size: 743 B |
After Width: | Height: | Size: 280 B |
After Width: | Height: | Size: 498 B |
After Width: | Height: | Size: 501 B |
After Width: | Height: | Size: 318 B |
After Width: | Height: | Size: 280 B |
After Width: | Height: | Size: 559 B |
After Width: | Height: | Size: 539 B |
After Width: | Height: | Size: 321 B |
After Width: | Height: | Size: 377 B |
After Width: | Height: | Size: 313 B |
After Width: | Height: | Size: 350 B |
After Width: | Height: | Size: 377 B |
After Width: | Height: | Size: 312 B |
After Width: | Height: | Size: 351 B |
After Width: | Height: | Size: 128 B |
After Width: | Height: | Size: 130 B |
After Width: | Height: | Size: 297 B |
After Width: | Height: | Size: 382 B |
After Width: | Height: | Size: 321 B |
After Width: | Height: | Size: 336 B |
After Width: | Height: | Size: 383 B |
After Width: | Height: | Size: 321 B |
After Width: | Height: | Size: 336 B |
After Width: | Height: | Size: 379 B |
After Width: | Height: | Size: 308 B |
After Width: | Height: | Size: 316 B |
After Width: | Height: | Size: 379 B |
After Width: | Height: | Size: 308 B |
After Width: | Height: | Size: 316 B |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 955 B |
After Width: | Height: | Size: 1.1 KiB |
@ -0,0 +1,26 @@ |
|||||
|
import { gameManager } from "@/Game"; |
||||
|
import { IPointData } from "pixi.js"; |
||||
|
|
||||
|
class Position { |
||||
|
static instance: Position = null |
||||
|
private constructor() { } |
||||
|
static getInstance() { |
||||
|
if (Position.instance == null) { |
||||
|
Position.instance = new Position |
||||
|
} |
||||
|
return Position.instance |
||||
|
} |
||||
|
|
||||
|
get(xType: "center", yType: "center", offset: Partial<IPointData>): IPointData { |
||||
|
let x, y |
||||
|
if (xType === 'center') { |
||||
|
x = gameManager.getInfo().width / 2 + (offset.x ?? 0) |
||||
|
} |
||||
|
if (yType === 'center') { |
||||
|
y = gameManager.getInfo().height / 2 + (offset.y ?? 0) |
||||
|
} |
||||
|
return { x, y } |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
export default Position.getInstance() |
@ -1,13 +1,17 @@ |
|||||
import { sound } from "@pixi/sound"; |
import { sound } from "@pixi/sound"; |
||||
import { LoaderResource } from "pixi.js"; |
// import { LoaderResource } from "pixi.js";
|
||||
|
|
||||
|
sound.add('my-sound', { |
||||
export function addSound(e: LoaderResource) { |
url: "/bg.mp3", |
||||
console.log(e); |
singleInstance: true, |
||||
sound.add(e.name, { |
autoPlay: false, |
||||
source: e.data, |
}); |
||||
singleInstance: true, |
// export function addSound(e: LoaderResource) {
|
||||
autoPlay: false, |
// console.log(e);
|
||||
}); |
// sound.add(e.name, {
|
||||
} |
// source: e.data,
|
||||
|
// singleInstance: true,
|
||||
|
// autoPlay: false,
|
||||
|
// });
|
||||
|
// }
|
||||
export default sound; |
export default sound; |
||||
|
@ -0,0 +1,24 @@ |
|||||
|
import { EP } from "@/enmu"; |
||||
|
import { defineWindow } from "@/Game"; |
||||
|
import { Container } from "pixi.js"; |
||||
|
|
||||
|
export default defineWindow( |
||||
|
class { |
||||
|
stage: Container = null; |
||||
|
|
||||
|
constructor(stage: Container) { |
||||
|
this.stage = stage; |
||||
|
} |
||||
|
bindStage(stage: Container){ |
||||
|
this.stage = stage; |
||||
|
} |
||||
|
|
||||
|
onLoad() { |
||||
|
console.log("global page loaded"); |
||||
|
} |
||||
|
|
||||
|
onUnLoad() { |
||||
|
} |
||||
|
}, |
||||
|
EP.Resident |
||||
|
); |
@ -1,26 +0,0 @@ |
|||||
import { EP } from "@/enmu"; |
|
||||
import { defineWindow } from "@/Game"; |
|
||||
import { Container, Loader } from "pixi.js"; |
|
||||
import { addSound } from "@/Game/Sound"; |
|
||||
|
|
||||
const loader = new Loader().add("my-sound", "/bg.mp3", (e) => addSound(e)); |
|
||||
|
|
||||
export default defineWindow("control", class { |
|
||||
stage: Container = null; |
|
||||
loader: Loader = loader; |
|
||||
|
|
||||
constructor(stage: Container) { |
|
||||
this.stage = stage; |
|
||||
} |
|
||||
|
|
||||
onLoad() { |
|
||||
console.log("onLoad control"); |
|
||||
} |
|
||||
|
|
||||
onUnLoad() { |
|
||||
console.log("onUnLoad control"); |
|
||||
} |
|
||||
|
|
||||
update() { |
|
||||
} |
|
||||
}, EP.Resident); |
|
@ -0,0 +1,101 @@ |
|||||
|
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, AnimatedSprite, Rectangle, utils } from "pixi.js"; |
||||
|
|
||||
|
// defineLoadResource([
|
||||
|
// { name: "my-sound", url: "/bg.mp3", callback: (e) => addSound(e) },
|
||||
|
// { name: "bg", url: "/bg.png" },
|
||||
|
// ])
|
||||
|
|
||||
|
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", |
||||
|
}); |
||||
|
this.title.x = gameManager.getInfo().width / 2; |
||||
|
this.title.y = gameManager.getInfo().height / 2 - 200; |
||||
|
this.title.position = Position.get("center", "center", { y: -200, x: 0 }) |
||||
|
this.title.anchor.set(0.5, 0.5); |
||||
|
this.stage.addChild(this.title); |
||||
|
|
||||
|
const plane9 = new NineSlicePlane(Texture.from("btn-bg"), 10, 10, 10, 10); |
||||
|
plane9.width = 100 |
||||
|
plane9.height = 50 |
||||
|
this.stage.addChild(plane9); |
||||
|
|
||||
|
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") |
||||
|
// 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 })
|
||||
|
//播放动画精灵
|
||||
|
this.pixie.gotoAndPlay(0); |
||||
|
// })
|
||||
|
// .start()
|
||||
|
}, |
||||
|
}); |
||||
|
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"); |
||||
|
} |
||||
|
|
||||
|
onUnLoad() { |
||||
|
Sound.stop("my-sound"); |
||||
|
console.log("onUnLoad loading"); |
||||
|
} |
||||
|
|
||||
|
update(dt: number) { |
||||
|
this.pixie.update(dt) |
||||
|
this.title.rotation -= 0.01 * dt; |
||||
|
} |
||||
|
|
||||
|
}, |
||||
|
); |
@ -1,64 +0,0 @@ |
|||||
import Button from "@/components/Button"; |
|
||||
import { gameManager, defineWindow, stageManager } from "@/Game"; |
|
||||
import Sound from "@/Game/Sound"; |
|
||||
import { Container, Sprite, Text, NineSlicePlane, Texture } from "pixi.js"; |
|
||||
import TWEEN from "@tweenjs/tween.js"; |
|
||||
|
|
||||
// defineLoadResource([
|
|
||||
// { name: "my-sound", url: "/bg.mp3", callback: (e) => addSound(e) },
|
|
||||
// { name: "bg", url: "/bg.png" },
|
|
||||
// ])
|
|
||||
|
|
||||
export default defineWindow( |
|
||||
"loading", |
|
||||
class { |
|
||||
stage: Container = null; |
|
||||
title: Text; // 标题
|
|
||||
|
|
||||
constructor(stage: Container) { |
|
||||
this.stage = stage; |
|
||||
} |
|
||||
|
|
||||
onLoad() { |
|
||||
console.log("onLoad loading"); |
|
||||
|
|
||||
this.title = new Text("时间魔法", { |
|
||||
fontSize: 80, |
|
||||
fill: "red", |
|
||||
}); |
|
||||
this.title.x = gameManager.getInfo().width / 2; |
|
||||
this.title.y = gameManager.getInfo().height / 2 - 200; |
|
||||
this.title.anchor.set(0.5, 0.5); |
|
||||
this.stage.addChild(this.title); |
|
||||
|
|
||||
const plane9 = new NineSlicePlane(Texture.from("bg"), 100, 100, 100, 100); |
|
||||
plane9.width = 300 |
|
||||
plane9.height = 300 |
|
||||
this.stage.addChild(plane9); |
|
||||
|
|
||||
const btn = Button({ |
|
||||
text: "开始游戏", |
|
||||
click: () => { |
|
||||
stageManager.changeStage("welcome") |
|
||||
// Sound.play("my-sound")
|
|
||||
// new TWEEN.Tween(btn).interpolation( TWEEN.Interpolation.Bezier )
|
|
||||
// .to({ alpha: .2,x:100, y:100 }, 1300)
|
|
||||
// .start()
|
|
||||
}, |
|
||||
}); |
|
||||
btn.x = gameManager.getInfo().width / 2 - btn.width / 2; |
|
||||
btn.y = gameManager.getInfo().height / 2 - btn.height / 2 + 200; |
|
||||
this.stage.addChild(btn); |
|
||||
} |
|
||||
|
|
||||
onUnLoad() { |
|
||||
Sound.stop("my-sound"); |
|
||||
console.log("onUnLoad loading"); |
|
||||
} |
|
||||
|
|
||||
update(dt: number) { |
|
||||
this.title.rotation -= 0.01 * dt; |
|
||||
} |
|
||||
|
|
||||
}, |
|
||||
); |
|