You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

51 lines
773 B

  1. define([
  2. 'js/sound/sound'
  3. ], function (
  4. soundManager
  5. ) {
  6. return {
  7. type: 'sound',
  8. sound: null,
  9. volume: 0,
  10. soundEntry: null,
  11. init: function () {
  12. const {
  13. sound, volume, music, defaultMusic, loop = true,
  14. obj: { zoneId, x, y, width, height, area }
  15. } = this;
  16. const config = {
  17. scope: zoneId,
  18. file: sound,
  19. volume,
  20. x,
  21. y,
  22. w: width,
  23. h: height,
  24. area,
  25. music,
  26. defaultMusic,
  27. loop
  28. };
  29. this.soundEntry = soundManager.addSound(config);
  30. },
  31. extend: function (bpt) {
  32. Object.assign(this, bpt);
  33. Object.assign(this.soundEntry, bpt);
  34. },
  35. destroy: function () {
  36. if (this.soundEntry?.sound)
  37. this.soundEntry?.sound.stop();
  38. soundManager.destroySoundEntry(this.soundEntry);
  39. }
  40. };
  41. });