SoundManager.js 782 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. var SoundManager = function( game, on ){
  2. this.game = game;
  3. this.theme = this.game.add.audio( 'theme' );
  4. this.place = this.game.add.audio( 'place' );
  5. this.crash = this.game.add.audio( 'crash' );
  6. this.perfect = this.game.add.audio( 'perfect' );
  7. this.mute = !on;
  8. };
  9. var p = SoundManager.prototype;
  10. p.switchSound = function( on ){
  11. this.mute = !on;
  12. if( on ){
  13. this.theme.resume();
  14. }else{
  15. this.theme.pause();
  16. }
  17. };
  18. p.playTheme = function() {
  19. if( !this.theme.isPlaying )
  20. this.theme.play('',0,1,true);
  21. if( this.mute )
  22. this.theme.pause();
  23. };
  24. p.playPlace = function() {
  25. if( !this.mute )
  26. this.place.play('', 0, 0.4);
  27. };
  28. p.playPerfect = function() {
  29. if( !this.mute )
  30. this.perfect.play();
  31. };
  32. p.playCrash = function() {
  33. if( !this.mute )
  34. this.crash.play();
  35. };