1549469775 3 years ago
parent
commit
4e70327b75
  1. 1
      index.html
  2. 1
      package.json
  3. 14
      pnpm-lock.yaml
  4. BIN
      public/bg.mp3
  5. 10
      src/Game/Sound.ts
  6. 4
      src/Game/index.ts
  7. 14
      src/main.ts
  8. 6
      src/stages/welcome/circle.ts
  9. 6
      src/stages/welcome/page_welcome.ts

1
index.html

@ -19,6 +19,5 @@
</head>
<body>
<script type="module" src="./src/main.ts"></script>
<audio src="https://g.mdcdn.cn/h5/music/act/sound2017/ms_canival_bgm.mp3" id="ms_canival_bgm" preload="auto" loop="loop" ></audio>
</body>
</html>

1
package.json

@ -10,6 +10,7 @@
"author": "",
"license": "ISC",
"dependencies": {
"@pixi/sound": "^4.0.6",
"pixi.js": "^6.2.0",
"vite": "^2.6.14",
"vite-tsconfig-paths": "^3.3.17"

14
pnpm-lock.yaml

@ -1,12 +1,14 @@
lockfileVersion: 5.3
specifiers:
'@pixi/sound': ^4.0.6
pixi.js: ^6.2.0
typescript: ^4.5.2
vite: ^2.6.14
vite-tsconfig-paths: ^3.3.17
dependencies:
'@pixi/sound': registry.npmmirror.com/@pixi/sound/4.0.6
pixi.js: registry.npmmirror.com/pixi.js/6.2.0
vite: registry.npmmirror.com/vite/2.6.14
vite-tsconfig-paths: registry.npmmirror.com/vite-tsconfig-paths/3.3.17_vite@2.6.14
@ -508,6 +510,18 @@ packages:
ismobilejs: registry.npmmirror.com/ismobilejs/1.1.1
dev: false
registry.npmmirror.com/@pixi/sound/4.0.6:
resolution: {integrity: sha1-KfNH9Sexa4CwFDcbU8fSxJfAGxQ=, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/@pixi/sound/download/@pixi/sound-4.0.6.tgz}
name: '@pixi/sound'
version: 4.0.6
engines: {node: '>=12', npm: '>=7', yarn: please-use-npm}
peerDependencies:
'@pixi/core': '>=5'
'@pixi/loaders': '>=5'
'@pixi/ticker': '>=5'
'@pixi/utils': '>=5'
dev: false
registry.npmmirror.com/@pixi/sprite-animated/6.2.0_def23276f715b15ee8a0503c2828bc32:
resolution: {integrity: sha1-sz3oBRKyNfg72CTTEX4IXqWrm/c=, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/@pixi/sprite-animated/download/@pixi/sprite-animated-6.2.0.tgz}
id: registry.npmmirror.com/@pixi/sprite-animated/6.2.0

BIN
public/bg.mp3

Binary file not shown.

10
src/Game/Sound.ts

@ -0,0 +1,10 @@
import { sound } from '@pixi/sound';
const Sound = sound.add('my-sound', {
url: "/bg.mp3",
autoPlay: true
});
console.log(Sound);
export default sound

4
src/Game/index.ts

@ -25,8 +25,8 @@ interface IWindow {
stage: Container;
onLoad?(): void;
onUnLoad?(): void;
lateUpdate?(dt: number): void;
update?(dt: number): void;
lateUpdate?(dt: number, name: string): void;
update?(dt: number, name: string): void;
}
export {
gameManager,

14
src/main.ts

@ -16,17 +16,11 @@ stageManager.watchStageChange((stage, lastStage) => {
}
});
gameManager.ticker.add((dt: number) => {
if(stageManager.curStage){
let curWindow = windows[stageManager.curStage.name];
residentList.forEach(v=>v.update&&v.update(dt))
curWindow.update && curWindow.update(dt);
residentList.forEach(v=>v.update&&v.update(dt, v.stage.name))
stageManager.curStage && curWindow && curWindow.update && curWindow.update(dt, curWindow.stage.name);
gameManager.render();
curWindow.lateUpdate && curWindow.lateUpdate(dt);
residentList.forEach(v=>v.lateUpdate&&v.lateUpdate(dt))
}else{
residentList.forEach(v=>v.update&&v.update(dt))
gameManager.render();
residentList.forEach(v=>v.lateUpdate&&v.lateUpdate(dt))
}
stageManager.curStage && curWindow && curWindow.lateUpdate && curWindow.lateUpdate(dt, curWindow.stage.name);
residentList.forEach(v=>v.lateUpdate&&v.lateUpdate(dt, v.stage.name))
});
stageManager.initStage("welcome");

6
src/stages/welcome/circle.ts

@ -1,5 +1,8 @@
import { stageManager } from "@/Game";
import { Graphics} from "pixi.js"
import Sound from "@/Game/Sound";
console.log(Sound);
export default new (class Circle{
render(){
@ -13,6 +16,9 @@ export default new (class Circle{
circle.interactive = true;
circle.buttonMode = true;
circle.on("touchend", ()=>{
setTimeout(() => {
Sound.play('my-sound');
}, 2000);
stageManager.changeStage("welcome2")
})
return circle

6
src/stages/welcome/page_welcome.ts

@ -1,9 +1,9 @@
import { EP } from "@/enmu";
import { stageManager, gameManager,defineWindow } from "@/Game";
import { Graphics, Sprite, Container, Text } from "pixi.js";
import { gameManager,defineWindow } from "@/Game";
import { Container, Text } from "pixi.js";
import Circle from "./circle"
defineWindow("welcome", class{
stage:Container = null

Loading…
Cancel
Save