readgo.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // Learn cc.Class:
  2. // - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/class.html
  3. // - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/class.html
  4. // Learn Attribute:
  5. // - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
  6. // - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/reference/attributes.html
  7. // Learn life-cycle callbacks:
  8. // - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
  9. // - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/life-cycle-callbacks.html
  10. cc.Class({
  11. extends: cc.Component,
  12. properties: {
  13. read: {
  14. default: null,
  15. type: cc.AudioClip
  16. },
  17. go: {
  18. default: null,
  19. type: cc.AudioClip
  20. },
  21. },
  22. // LIFE-CYCLE CALLBACKS:
  23. onLoad () {
  24. app.readGo = this;
  25. this.sounds = [];
  26. this.sounds.push(this.read);
  27. this.sounds.push(this.go);
  28. },
  29. start () {
  30. },
  31. readgo: function (callback) {
  32. this.node.active = true;
  33. app.bgm.stop();
  34. let an = this.node.getComponent(cc.Animation);
  35. an.play();
  36. cc.audioEngine.play(this.sounds[0],false,1);
  37. setTimeout(function () {
  38. cc.audioEngine.play(this.sounds[1],false,1);
  39. setTimeout(function () {
  40. this.node.active = false;
  41. if (callback!=null) {
  42. callback();
  43. }
  44. app.bgm.play();
  45. }.bind(this),700)
  46. }.bind(this),1100)
  47. },
  48. // update (dt) {},
  49. });