npmrun 1 year ago
parent
commit
c6aeb0d195
  1. 1957
      package-lock.json
  2. 1
      src/Game/Game.ts
  3. 11
      src/Game/Stage.ts
  4. 3
      src/stages/page_loading.ts
  5. 20
      src/stages/welcome/page_welcome.ts

1957
package-lock.json

File diff suppressed because it is too large

1
src/Game/Game.ts

@ -131,7 +131,6 @@ export default class Game {
this._renderer = renderer; this._renderer = renderer;
document.body.appendChild(renderer.view); document.body.appendChild(renderer.view);
this.updateView();
window.addEventListener("resize", () => { window.addEventListener("resize", () => {
this.updateView(); this.updateView();
}); });

11
src/Game/Stage.ts

@ -62,6 +62,12 @@ export default class Stage {
lastStage.stage.visible = false lastStage.stage.visible = false
} }
let curStage = this._stages[name]; let curStage = this._stages[name];
if(curStage && typeof curStage === "string"){
this.create(name, EP.Normal)
curStage = this._stages[name]
console.log(curStage);
}
this.curStage = curStage this.curStage = curStage
if(curStage&&curStage.type === EP.Normal){ if(curStage&&curStage.type === EP.Normal){
this.gameManager.stage.addChild(curStage.stage) this.gameManager.stage.addChild(curStage.stage)
@ -69,6 +75,11 @@ export default class Stage {
curStage.stage.visible = true curStage.stage.visible = true
} }
this._wscb.forEach(v=>v(curStage, lastStage)) this._wscb.forEach(v=>v(curStage, lastStage))
if(lastStage&&lastStage.type === EP.Normal){
lastStage.stage.destroy()
this._stages[lastStage.name] = "已销毁" as any
}
} }
getStage(name: string, type: EP = EP.Normal): Container{ getStage(name: string, type: EP = EP.Normal): Container{

3
src/stages/page_loading.ts

@ -21,6 +21,7 @@ export default defineWindow(
onLoad() { onLoad() {
console.log("onLoad loading"); console.log("onLoad loading");
this.title = new Text("时间魔法", { this.title = new Text("时间魔法", {
fontSize: 80, fontSize: 80,
fill: "red", fill: "red",
@ -38,7 +39,7 @@ export default defineWindow(
const btn = Button({ const btn = Button({
text: "开始游戏", text: "开始游戏",
click: () => { click: () => {
// stageManager.changeStage("welcome") stageManager.changeStage("welcome")
// Sound.play("my-sound") // Sound.play("my-sound")
// new TWEEN.Tween(btn).interpolation( TWEEN.Interpolation.Bezier ) // new TWEEN.Tween(btn).interpolation( TWEEN.Interpolation.Bezier )
// .to({ alpha: .2,x:100, y:100 }, 1300) // .to({ alpha: .2,x:100, y:100 }, 1300)

20
src/stages/welcome/page_welcome.ts

@ -1,13 +1,15 @@
import Button from "@/components/Button"; import Button from "@/components/Button";
import { gameManager,defineWindow, stageManager } from "@/Game"; import { gameManager,defineWindow, stageManager } from "@/Game";
import Sound from "@/Game/Sound"; import Sound from "@/Game/Sound";
import { Container, Text } from "pixi.js"; import { Container, Graphics, Text } from "pixi.js";
import Circle from "./circle" import Circle from "./circle"
export default defineWindow("welcome", class{ export default defineWindow("welcome", class{
stage:Container = null stage:Container = null
elements: Record<string, Graphics> = {}
text: any
constructor(stage: Container){ constructor(stage: Container){
this.stage = stage this.stage = stage
@ -19,13 +21,13 @@ export default defineWindow("welcome", class{
circle.on("touchend", ()=>{ circle.on("touchend", ()=>{
stageManager.changeStage("welcome2") stageManager.changeStage("welcome2")
}) })
let text = new Text("修仙人生日常") this.text = new Text("修仙人生日常")
text.x = gameManager.getInfo().width-text.width
text.y = gameManager.getInfo().height-text.height this.stage.addChild(this.text)
this.stage.addChild(text)
const btn = Button({text: "修仙人生日常"}) const btn = Button({text: "修仙人生日常"})
btn.on("touchend", ()=>{ btn.on("touchend", ()=>{
Sound.play('my-sound'); // Sound.play('my-sound');
stageManager.changeStage("loading")
}) })
this.stage.addChild(btn) this.stage.addChild(btn)
} }
@ -33,7 +35,9 @@ export default defineWindow("welcome", class{
Sound.stop("my-sound") Sound.stop("my-sound")
console.log("onUnLoad 1"); console.log("onUnLoad 1");
} }
// update(){ update(){
this.text.x = gameManager.getInfo().width-this.text.width
this.text.y = gameManager.getInfo().height-this.text.height
// console.log(22); // console.log(22);
// } }
}) })
Loading…
Cancel
Save