ready.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. // Learn cc.Class:
  2. // - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/class.html
  3. // - [English] http://docs.cocos2d-x.org/creator/manual/en/scripting/class.html
  4. // Learn Attribute:
  5. // - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
  6. // - [English] http://docs.cocos2d-x.org/creator/manual/en/scripting/reference/attributes.html
  7. // Learn life-cycle callbacks:
  8. // - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
  9. // - [English] https://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html
  10. cc.Class({
  11. extends: cc.Component,
  12. properties: {
  13. readgo: cc.Node,
  14. canvas: cc.Node,
  15. },
  16. // LIFE-CYCLE CALLBACKS:
  17. // onLoad () {},
  18. start() {
  19. // this.init();
  20. },
  21. init : function(){
  22. this.ready();
  23. this.canvas.getComponent("dadishu").setRestartCallBack(function () {
  24. console.log("重新开始给android");
  25. utils.isMobile(function () {
  26. //给数据到设备
  27. manager_android_js.restStartGame();
  28. }.bind(this));
  29. this.ready(function () {
  30. }.bind(this));
  31. }.bind(this));
  32. },
  33. ready: function (callback) {
  34. if (callback != null) {
  35. // this.canvas.getComponent("dadishu").重新开始();
  36. }
  37. this.readgo.active = true;
  38. this.readgo.getChildByName("readyGo").getComponent(dragonBones.ArmatureDisplay).playAnimation("animation", 1);
  39. this.readgo.getChildByName("readyGoBg").getComponent(cc.Animation).play();
  40. this.readgo.getComponent(cc.AudioSource).volume = MySetting.sound_value;
  41. this.readgo.getComponent(cc.AudioSource).play();
  42. this.scheduleOnce(function () {
  43. this.readgo.active = false;
  44. if (callback != null) {
  45. this.canvas.getComponent("dadishu").初始化();
  46. } else {
  47. this.canvas.getComponent("dadishu").countDownTime();
  48. }
  49. }.bind(this), 2)
  50. }
  51. // update (dt) {},
  52. });