new.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  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. new_layout: cc.Node
  14. },
  15. // LIFE-CYCLE CALLBACKS:
  16. // onLoad () {},
  17. start() {
  18. //测试这样用 正式注释就行了
  19. // this.init();
  20. },
  21. init: function () {
  22. this._parent = this.new_layout;
  23. this.Allows = this.getNode("Allows");
  24. this.Forbiddens = this.getNode("Forbiddens");
  25. this.RivalTip = this.getNode("RivalTip");
  26. this.SelfTip = this.getNode("SelfTip");
  27. this.Hand = this.getNode("Hand");
  28. this.LifeTip1 = this.getNode("LifeTip1");
  29. this.LifeTip2 = this.getNode("LifeTip2");
  30. this.LifeTip3 = this.getNode("LifeTip3");
  31. this.process1();
  32. },
  33. // 显示 下面三个箭头 和上面的 提示板
  34. process1: function () {
  35. this.Allows.active = true;
  36. var childrens = this.Allows.children;
  37. for (var i = 0; i < childrens.length; i++) {
  38. var actionTo1 = cc.scaleTo(1, 1.25, 1.25);
  39. var actionTo2 = cc.scaleTo(1, 1, 1);
  40. var rep = cc.repeat(cc.sequence(actionTo1, actionTo2), 5);
  41. childrens[i].runAction(rep);
  42. var move1 = cc.moveBy(1, 0, 50);
  43. // var spawn = cc.spawn(move1, rep);
  44. var move2 = cc.moveBy(1, 0, 0);
  45. var move3 = cc.moveBy(1, 0, -50);
  46. var move4 = cc.moveBy(1, 0, 0);
  47. var r = cc.repeat(cc.sequence(move1, move2, move3, move4), 5);
  48. childrens[i].runAction(r);
  49. }
  50. var showAllowsCallback = function () {
  51. this.SelfTip.active = true;
  52. this.process2();
  53. }
  54. this.scheduleOnce(showAllowsCallback, 5)
  55. },
  56. // 隐藏 三个箭头 和 我方提示板
  57. process2: function () {
  58. var hintAllowsCallback = function () {
  59. this.SelfTip.active = false;
  60. this.Allows.active = false;
  61. this.process3();
  62. }
  63. this.scheduleOnce(hintAllowsCallback, 5)
  64. },
  65. // 显示 三个禁止 和 对方方提示板
  66. process3: function () {
  67. this.Forbiddens.active = true;
  68. var childrens = this.Forbiddens.children;
  69. for (var i = 0; i < childrens.length; i++) {
  70. var actionTo1 = cc.scaleTo(1, 0.6, 0.6);
  71. var actionTo2 = cc.scaleTo(1, 0.45, 0.45);
  72. var rep = cc.repeat(cc.sequence(actionTo1, actionTo2), 5);
  73. childrens[i].runAction(rep);
  74. }
  75. var showAllowsCallback = function () {
  76. this.RivalTip.active = true;
  77. this.process4();
  78. }
  79. this.scheduleOnce(showAllowsCallback, 5)
  80. },
  81. // 隐藏 所有
  82. process4: function () {
  83. this.Forbiddens.active = false;
  84. var hintAllowsCallback = function () {
  85. this.process5();
  86. }
  87. this.scheduleOnce(hintAllowsCallback, 5)
  88. },
  89. process5: function () {
  90. this.RivalTip.active = false;
  91. this.Hand.active = true;
  92. var Hands = this.Hand.children;
  93. for (var i = 0; i < Hands.length; i++) {
  94. var actionTo1 = cc.scaleTo(1, 1.5, 1.5);
  95. var actionTo2 = cc.scaleTo(1, 1, 1);
  96. var rep = cc.repeat(cc.sequence(actionTo1, actionTo2), 5);
  97. Hands[i].runAction(rep);
  98. }
  99. var hintAllowsCallback = function () {
  100. this.process6();
  101. }
  102. this.scheduleOnce(hintAllowsCallback, 5)
  103. },
  104. process6: function () {
  105. this.Hand.active = false;
  106. var hintAllowsCallback = function () {
  107. this.process7();
  108. }
  109. this.scheduleOnce(hintAllowsCallback, 1)
  110. },
  111. process7: function () {
  112. this.LifeTip1.active = true;
  113. var hintAllowsCallback = function () {
  114. this.LifeTip1.active = false;
  115. this.process8();
  116. }
  117. this.scheduleOnce(hintAllowsCallback, 4)
  118. },
  119. process8: function () {
  120. this.LifeTip2.active = true;
  121. var hintAllowsCallback = function () {
  122. this.LifeTip2.active = false;
  123. this.process9();
  124. }
  125. this.scheduleOnce(hintAllowsCallback, 4)
  126. },
  127. process9: function () {
  128. this.LifeTip3.active = true;
  129. var hintAllowsCallback = function () {
  130. this.LifeTip3.active = false;
  131. this.processLast();
  132. }
  133. this.scheduleOnce(hintAllowsCallback, 4)
  134. },
  135. // 隐藏 所有
  136. processLast: function () {
  137. var hintAllowsCallback = function () {
  138. // this.Forbiddens.active = false;
  139. // this.RivalTip.active = false;
  140. this.processEnd();
  141. }
  142. this.scheduleOnce(hintAllowsCallback, 1)
  143. },
  144. processEnd: function () {
  145. console.log("准备去倒计时");
  146. if (this.processCallback != null) {
  147. this.processCallback();
  148. }
  149. },
  150. setProcessCallback: function (processCallback) {
  151. this.processCallback = processCallback;
  152. },
  153. processCallback: function () {
  154. },
  155. getNode: function (name, parent) {
  156. if (parent == null) {
  157. return this._parent.getChildByName(name);
  158. } else {
  159. return parent.getChildByName(name);
  160. }
  161. },
  162. // update (dt) {},
  163. });