AudioManager.ts 693 B

1234567891011121314151617181920
  1. import { _decorator, AudioSource, Component } from 'cc';
  2. import { GameEventEnum } from './GameStruct';
  3. const { ccclass, property } = _decorator;
  4. @ccclass('AudioManager')
  5. export class AudioManager extends Component {
  6. onLoad() {
  7. window.gm.node.on(GameEventEnum.ReadyGo, () => {
  8. this.node.getChildByName("ready-go").getComponent(AudioSource).play();
  9. });
  10. window.gm.node.on(GameEventEnum.GameWin, () => {
  11. this.node.getChildByName("Cheers").getComponent(AudioSource).play();
  12. });
  13. window.gm.node.on(GameEventEnum.GameLose, () => {
  14. this.node.getChildByName("Boos").getComponent(AudioSource).play();
  15. });
  16. }
  17. }