Browse Source

fixed bug

master
npmrun 3 years ago
parent
commit
e6b2a7f802
  1. 1
      .gitignore
  2. 1
      .npmrc
  3. 13
      package.json
  4. 1416
      pnpm-lock.yaml
  5. 4
      src/Game/index.ts
  6. 1
      src/components/Button.ts
  7. 11
      src/stages/page_loading.ts
  8. 4
      tsconfig.json
  9. 25
      vite.config.ts

1
.gitignore

@ -1,2 +1,3 @@
node_modules node_modules
.cache .cache
dist

1
.npmrc

@ -0,0 +1 @@
auto-install-peers=true

13
package.json

@ -4,19 +4,20 @@
"description": "", "description": "",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"dev": "vite --host" "dev": "vite --host",
"build": "vite build"
}, },
"keywords": [], "keywords": [],
"author": "", "author": "",
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"@pixi/sound": "^4.0.6", "@pixi/sound": "^4.3.0",
"@tweenjs/tween.js": "^18.6.4", "@tweenjs/tween.js": "^18.6.4",
"pixi.js": "^6.2.0", "pixi.js": "^6.5.3",
"vite": "^2.6.14", "vite": "^2.9.15",
"vite-tsconfig-paths": "^3.3.17" "vite-tsconfig-paths": "^3.5.0"
}, },
"devDependencies": { "devDependencies": {
"typescript": "^4.5.2" "typescript": "^4.8.3"
} }
} }

1416
pnpm-lock.yaml

File diff suppressed because it is too large

4
src/Game/index.ts

@ -1,7 +1,8 @@
import Game from "./Game"; import Game from "./Game";
import Stage from "./Stage"; import Stage from "./Stage";
import {Container} from "pixi.js" import {Container} from "pixi.js"
import { EDirection, EP } from "@/enmu"; import { EP } from "@/enmu";
import TWEEN from "@tweenjs/tween.js";
const gameManager = Game.getInstance(); const gameManager = Game.getInstance();
const stageManager = Stage.getInstance(); const stageManager = Stage.getInstance();
@ -44,6 +45,7 @@ stageManager.watchStageChange((stage, lastStage) => {
gameManager.ticker.add((dt: number) => { gameManager.ticker.add((dt: number) => {
if (!stageManager.curStage) return; if (!stageManager.curStage) return;
let curWindow = windows[stageManager.curStage.name]; let curWindow = windows[stageManager.curStage.name];
TWEEN.update();
residentList.forEach((v) => v.update && v.update(dt, v.stage.name)); residentList.forEach((v) => v.update && v.update(dt, v.stage.name));
stageManager.curStage && stageManager.curStage &&
curWindow && curWindow &&

1
src/components/Button.ts

@ -47,7 +47,6 @@ export default function Button(opts: Partial<IOpts>) {
button.addChild(rect); button.addChild(rect);
button.addChild(textStr); button.addChild(textStr);
button.x = 100; button.x = 100;
button.y = 50; button.y = 50;
button.interactive = true; button.interactive = true;

11
src/stages/page_loading.ts

@ -21,12 +21,13 @@ defineWindow(
text.x = gameManager.getInfo().width / 2 - text.width / 2; text.x = gameManager.getInfo().width / 2 - text.width / 2;
text.y = gameManager.getInfo().height / 2 - text.height / 2 - 500; text.y = gameManager.getInfo().height / 2 - text.height / 2 - 500;
this.stage.addChild(text); this.stage.addChild(text);
const btn = Button({ const btn = Button({
text: "开始游戏", text: "开始游戏",
click() { click:()=>{
// Sound.play("my-sound") // Sound.play("my-sound")
new TWEEN.Tween(btn).interpolation( TWEEN.Interpolation.Bezier ).to({ x: 100, y: 100, alpha: .2 }, 1000).start(); 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.x = gameManager.getInfo().width / 2 - btn.width / 2;
@ -37,8 +38,8 @@ defineWindow(
Sound.stop("my-sound"); Sound.stop("my-sound");
console.log("onUnLoad loading"); console.log("onUnLoad loading");
} }
update() { update(dt: number) {
TWEEN.update();
} }
} }

4
tsconfig.json

@ -4,13 +4,13 @@
"noImplicitAny": true, "noImplicitAny": true,
"sourceMap": true, "sourceMap": true,
"lib": ["ES2015", "DOM"], "lib": ["ES2015", "DOM"],
"module": "ESNext", "module": "ES6",
"moduleResolution": "node", "moduleResolution": "node",
"allowSyntheticDefaultImports": true, "allowSyntheticDefaultImports": true,
"experimentalDecorators": true, "experimentalDecorators": true,
"noUnusedLocals": true, "noUnusedLocals": true,
"noUnusedParameters": true, "noUnusedParameters": true,
"target": "es5", "target": "ES6",
"esModuleInterop": true, "esModuleInterop": true,
"baseUrl": ".", "baseUrl": ".",
"paths": { "paths": {

25
vite.config.ts

@ -2,5 +2,30 @@ import { defineConfig } from "vite";
import tsconfigPaths from "vite-tsconfig-paths"; import tsconfigPaths from "vite-tsconfig-paths";
export default defineConfig({ export default defineConfig({
build: {
rollupOptions: {
output: {
manualChunks(id) {
if (id.includes("node_modules/pixi.js")) {
return "pixi"
} else if (id.includes("node_modules/@pixi/sound")) {
return "pixi_sound"
} else if (id.includes("node_modules/@pixi")) {
return "pixi_module"
} else if (id.includes("node_modules")) {
return "vendor"
}
},
entryFileNames: 'game.js',
},
},
minify: "terser",
terserOptions: {
compress: {
drop_console: true,
drop_debugger: true,
},
},
},
plugins: [tsconfigPaths()], plugins: [tsconfigPaths()],
}); });

Loading…
Cancel
Save