login.js 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. window.RootNode = {
  2. soundNode : null,
  3. closeButton : null,
  4. dialog : null,
  5. }
  6. window.app = {
  7. AETime : 280,
  8. //系数数组
  9. punchHitVars : [0.1,0.5,1.2]
  10. }
  11. cc.Class({
  12. extends: cc.Component,
  13. properties: {
  14. },
  15. onLoad (){
  16. // httpUtils.Get(httpUtils.httpGetTable,null,function (data) {
  17. // console.log("成功",data)
  18. // // if (data.code == 0) {
  19. // // app.AETime = data.data.AETime;
  20. // // app.punchHitVars.push(data.data.firstPunchHitVar);
  21. // // app.punchHitVars.push(data.data.secondPunchHitVar);
  22. // // app.punchHitVars.push(data.data.thirdPunchHitVar);
  23. // // }
  24. // }.bind(this),function (data) {
  25. // console.log("失败",data)
  26. // }.bind(this));
  27. },
  28. _init : function(data){
  29. app.AETime = data.AETime;
  30. app.punchHitVars = [];
  31. app.punchHitVars.push(data.firstPunchHitVar);
  32. app.punchHitVars.push(data.secondPunchHitVar);
  33. app.punchHitVars.push(data.thirdPunchHitVar);
  34. console.log("设置网络数据",app)
  35. },
  36. circleMove (dt) {
  37. // 先计算弧度
  38. this.radian -= dt * (this.carSpeed/100);
  39. let x = this.circleRadius * Math.cos(this.radian) + this.circleCenter.x;
  40. let y = this.circleRadius * Math.sin(this.radian) + this.circleCenter.y;
  41. // let angle = 360- 180/Math.PI*this.radian;
  42. // this.Earth.angle = angle;
  43. //console.log('x = ' + x + ' y = ' + y + ' angle = ' + angle);
  44. this.Earth.position = cc.v2(x, y);
  45. },
  46. start() {
  47. this.TutorialFlag = false;
  48. this.Earth = UtilsPrefabs.getNode("Earth", this.node);
  49. let EX = this.Earth.position.x;
  50. let EY = this.Earth.position.y;
  51. // 圆心
  52. this.circleCenter = cc.v2(EX, EY);
  53. // 半径
  54. this.circleRadius = 10;
  55. // 车速
  56. this.carSpeed = 150;
  57. // 弧度
  58. this.radian = 10;
  59. this.clickStart = 0;
  60. //地球转动动画
  61. //this.schedule(this.circleMove, 0.01);
  62. this.soundNode = cc.find("sound");
  63. cc.game.addPersistRootNode(this.soundNode);
  64. RootNode.soundNode = this.soundNode;
  65. this.c = cc.find("c");
  66. this.closeButton = UtilsPrefabs.getNode("closeButton", this.c);
  67. // this.closeButton = cc.find("closeButton");
  68. cc.game.addPersistRootNode(this.c);
  69. RootNode.closeButton = this.c;
  70. cc.log("数据是啥 login",RootNode);
  71. // this.dialog = cc.find("dialog");
  72. // cc.game.addPersistRootNode(this.dialog);
  73. // RootNode.dialog = this.dialog;
  74. this.scheduleOnce(function () {
  75. this.Login_ClipID = this.soundNode.getComponent("soundManage").playLogin();
  76. this.PlayStartToPlayTutorialSound();
  77. }.bind(this),1);
  78. //
  79. // this.schedule(function () {
  80. // this.soundNode.getComponent("soundManage").startToPlayTutorial();
  81. // }.bind(this),7);
  82. // this.StartGameTime = setTimeout(function () {
  83. // this.soundNode.getComponent("soundManage").playStartGame();
  84. // }.bind(this),10000);
  85. utils.redytoLoadScene("main");
  86. utils.redytoLoadScene("Multi_function");
  87. utils.isMobile(function () {
  88. Manager.sceneType = 0;
  89. Manager.login = this;
  90. Manager.getNavigator();
  91. }.bind(this));
  92. this.StarBtn = UtilsPrefabs.getNode("go", this.node);
  93. this.Title = UtilsPrefabs.getNode("Title", this.node)
  94. let EarthAnim = this.EarthAnim=UtilsPrefabs.getNode("Earth", this.node).getComponent(cc.Animation);
  95. //let TitleAnim = this.TitleAnim = UtilsPrefabs.getNode("Title", this.node).getComponent(cc.Animation);
  96. //let BeginBtnAnim =this.BeginBtnAnim = go.getComponent(cc.Animation);
  97. EarthAnim.on('stop', this.onStop, this);
  98. UtilsPrefabs.setOn(this.StarBtn, function () {
  99. // utils.toLoadScene("main")
  100. this.goMain();
  101. }.bind(this));
  102. },
  103. PlayLoginSound:function()
  104. {
  105. this.scheduleOnce(function () {
  106. this.PlayLoginSchedule();
  107. }.bind(this),10);
  108. },
  109. PlayStartToPlayTutorialSound:function()
  110. {
  111. this.scheduleOnce(function () {
  112. this.PlayStartToPlayTutorialSchedule();
  113. }.bind(this),7);
  114. },
  115. //播放新手教程
  116. PlayTutorial:function()
  117. {
  118. if(this.TutorialFlag)return;
  119. this.TutorialFlag = true;
  120. this.soundNode.getComponent("soundManage").stop(this.Login_ClipID);
  121. this.soundNode.getComponent("soundManage").stop(this.StartToPlayTutorial_ClipID);
  122. this.unscheduleAllCallbacks();
  123. // this.unschedule(this.PlayLoginSchedule);
  124. // this.unschedule(this.PlayStartToPlayTutorialSchedule);
  125. this.scheduleOnce(function () {
  126. this.Tutorial_ClipID=this.soundNode.getComponent("soundManage").playTutorial();
  127. cc.audioEngine.setFinishCallback(this.Tutorial_ClipID, function () {
  128. this.TutorialFlag = false;
  129. }.bind(this));
  130. }.bind(this),1);
  131. this.scheduleOnce(function () {
  132. this.PlayLoginSound();
  133. }.bind(this),35);
  134. },
  135. PlayLoginSchedule:function()
  136. {
  137. this.Login_ClipID=this.soundNode.getComponent("soundManage").playLogin();
  138. this.PlayStartToPlayTutorialSound();
  139. },
  140. PlayStartToPlayTutorialSchedule:function()
  141. {
  142. this.StartToPlayTutorial_ClipID=this.soundNode.getComponent("soundManage").startToPlayTutorial();
  143. this.PlayLoginSound();
  144. },
  145. goMain : function(){
  146. this.clickStart++;
  147. if (this.clickStart > 1) {
  148. return;
  149. }
  150. // this.StarBtn.getComponent(cc.Button).interactable = false;
  151. this.unschedule(this.circleMove);
  152. let MoveUp = cc.moveBy(0.5,cc.v2(0,1000)).easing(cc.easeIn(10));
  153. let MoveDown = cc.moveBy(0.5,cc.v2(0,-1000)).easing(cc.easeIn(10));
  154. this.Title.runAction(MoveUp);
  155. // StarBtn.runAction(MoveDown);
  156. let Finish = cc.callFunc(function() {
  157. //this.EarthAnim.play();
  158. let _armatureDisplay = this.Earth.getComponent("dragonBones.ArmatureDisplay");
  159. _armatureDisplay.playAnimation("02_1",1);
  160. _armatureDisplay.addEventListener(dragonBones.EventObject.COMPLETE, (event)=>{
  161. cc.log("complete");
  162. let MoveUp = cc.moveBy(0.5,cc.v2(0,1500));
  163. let Finish2 = cc.callFunc(function() {
  164. utils.toLoadScene("main");
  165. }, this);
  166. var seq = cc.sequence(MoveUp.easing(cc.easeIn(0.5)), Finish2);
  167. this.Earth.runAction(seq);
  168. },this);
  169. _armatureDisplay.addEventListener(dragonBones.EventObject.START, (event)=>{
  170. cc.log("start");
  171. },this);
  172. _armatureDisplay.addEventListener(dragonBones.EventObject.LOOP_COMPLETE, (event)=>{
  173. cc.log("loop complete");
  174. },this);
  175. }, this);
  176. // var spawn = cc.spawn(cc.moveBy(0.5, 0, 50), cc.scaleTo(0.5, 0.8, 1.4));
  177. var seq = cc.sequence(MoveDown, Finish);
  178. this.StarBtn.runAction(seq );
  179. // this.soundNode.getComponent("soundManage").stop(this.soundNode.getComponent("soundManage").Login_ClipID);
  180. //this.soundNode.getComponent("soundManage").stop(this.soundNode.getComponent("soundManage").StartGame_ClipID);
  181. this.soundNode.getComponent("soundManage").stopAllSoundEffect();
  182. this.unscheduleAllCallbacks();
  183. clearTimeout(this.StartGameTime);
  184. },
  185. onStop: function () {
  186. utils.toLoadScene("main");
  187. },
  188. });