PlaySoundInAni.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. var t = require;
  2. var e = module;
  3. var i = exports;
  4. var s =
  5. (this && this.__decorate) ||
  6. function(t, e, i, s) {
  7. var o,
  8. a = arguments.length,
  9. n = a < 3 ? e : null === s ? (s = Object.getOwnPropertyDescriptor(e, i)) : s;
  10. if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) n = Reflect.decorate(t, e, i, s);
  11. else
  12. for (var r = t.length - 1; 0 <= r; r--)
  13. (o = t[r]) && (n = (a < 3 ? o(n) : 3 < a ? o(e, i, n) : o(e, i)) || n);
  14. return 3 < a && n && Object.defineProperty(e, i, n), n;
  15. };
  16. Object.defineProperty(i, "__esModule", { value: !0 });
  17. const { ccclass: o, property: a, menu: n } = cc._decorator;
  18. e = class extends cc.Component {
  19. constructor() {
  20. super(...arguments),
  21. (this._volnumber = 1),
  22. (this._curChannel = -1),
  23. (this._audio = null),
  24. (this._play = !1),
  25. (this._loop = !1);
  26. }
  27. set audio(t) {
  28. t != this._audio &&
  29. (this._audio = t) &&
  30. this._play &&
  31. (this._curChannel = cc.audioEngine.play(t, this._loop, this._volnumber));
  32. }
  33. get audio() {
  34. return this._audio;
  35. }
  36. set play(t) {
  37. this._play != t &&
  38. ((this._play = t) ?
  39. (0 <= this._curChannel && cc.audioEngine.stop(this._curChannel),
  40. this._audio && (this._curChannel = cc.audioEngine.play(this._audio, this._loop, this._volnumber))) :
  41. 0 <= this._curChannel && (cc.audioEngine.stop(this._curChannel), (this._curChannel = -1)));
  42. }
  43. get play() {
  44. return this._play;
  45. }
  46. set loop(t) {
  47. this._loop != t &&
  48. ((this._loop = t),
  49. this._play && this._audio && (this._curChannel = cc.audioEngine.play(this._audio, t, this._volnumber)));
  50. }
  51. get loop() {
  52. return this._loop;
  53. }
  54. onLoad() {}
  55. };
  56. s([a({})], e.prototype, "_volnumber", void 0),
  57. s([a({ type: cc.AudioClip })], e.prototype, "_audio", void 0),
  58. s([a({ type: cc.AudioClip })], e.prototype, "audio", null),
  59. s([a], e.prototype, "_play", void 0),
  60. s([a({})], e.prototype, "play", null),
  61. s([a], e.prototype, "_loop", void 0),
  62. s([a({})], e.prototype, "loop", null),
  63. (e = s([o], e)),
  64. (i.default = e);