AudioUtils.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. cc.Class({
  2. extends: cc.Component,
  3. properties: {
  4. swap: {
  5. type: cc.AudioClip,
  6. default: null
  7. },
  8. click: {
  9. type: cc.AudioClip,
  10. default: null
  11. },
  12. eliminate:{
  13. type: [cc.AudioClip],
  14. default: [],
  15. },
  16. continuousMatch:{
  17. type: [cc.AudioClip],
  18. default: []
  19. }
  20. },
  21. // LIFE-CYCLE CALLBACKS:
  22. onLoad () {
  23. },
  24. start () {
  25. },
  26. playClick: function(){
  27. cc.audioEngine.play(this.click, false, 1);
  28. },
  29. playSwap: function(){
  30. cc.audioEngine.play(this.swap, false, 1);
  31. },
  32. playEliminate: function(step){
  33. step = Math.min(this.eliminate.length - 1, step);
  34. cc.audioEngine.play(this.eliminate[step], false, 1);
  35. },
  36. playContinuousMatch: function(step){
  37. // console.log("step = ", step);
  38. step = Math.min(step, 11);
  39. if(step < 2){
  40. return
  41. }
  42. cc.audioEngine.play(this.continuousMatch[Math.floor(step/2) - 1], false, 1);
  43. }
  44. // update (dt) {},
  45. });