help.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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. // foo: {
  14. // // ATTRIBUTES:
  15. // default: null, // The default value will be used only when the component attaching
  16. // // to a node for the first time
  17. // type: cc.SpriteFrame, // optional, default is typeof default
  18. // serializable: true, // optional, default is true
  19. // },
  20. // bar: {
  21. // get () {
  22. // return this._bar;
  23. // },
  24. // set (value) {
  25. // this._bar = value;
  26. // }
  27. // },
  28. },
  29. // LIFE-CYCLE CALLBACKS:
  30. onLoad () {
  31. // console.log("现在 我的属性是",this.node);
  32. this._init();
  33. },
  34. _init : function(){
  35. this.Canvas = cc.find("Canvas/UICamera");
  36. this.helpPrefab = [
  37. "prefab/task/taskPrefab3",
  38. "prefab/help/helpPrefab1",
  39. "prefab/task/taskPrefab4",
  40. "prefab/task/taskPrefab6",
  41. "prefab/task/taskPrefab7",
  42. "prefab/task/taskPrefab8",
  43. "prefab/help/helpPrefab6",
  44. "prefab/task/taskPrefab11",
  45. "prefab/task/taskPrefab12",
  46. "prefab/task/taskPrefab13",
  47. "prefab/task/taskPrefab13",
  48. ]
  49. this.curr = 0;
  50. this.close = UtilsPrefabs.getNode("close",this.node);
  51. this.listview = UtilsPrefabs.getNode("listview",this.node);
  52. this.layoutbutton = UtilsPrefabs.getNode("layoutbutton",this.node);
  53. this.up = UtilsPrefabs.getNode("up",this.layoutbutton);
  54. this.down = UtilsPrefabs.getNode("down",this.layoutbutton);
  55. for (var i = 0; i < this.listview.children.length; i++) {
  56. this.listview.children[i].active = false;
  57. }
  58. this.listview.children[this.curr].active = true;
  59. this.buttonHelp();
  60. this.isShowButton();
  61. this.onCallback();
  62. },
  63. buttonHelp : function(){
  64. this.arrbuttonHelp = [];
  65. for (var i = 0; i < this.listview.children.length; i++) {
  66. var childrens = this.listview.children[i];
  67. for (var y = 0; y < childrens.children.length; y++) {
  68. var button = childrens.children[y]
  69. .getChildByName("New Node")
  70. .getChildByName("guide")
  71. button.itemPosition = this.arrbuttonHelp.length;
  72. this.arrbuttonHelp.push(button);
  73. }
  74. }
  75. // console.log("是什么呢长度",this.arrbuttonHelp);
  76. for (var i = 0; i < this.arrbuttonHelp.length; i++) {
  77. var button = this.arrbuttonHelp[i];
  78. UtilsPrefabs.setOn(button,function (e) {
  79. // this.setOnCallback(this.arrbuttonHelp[e.target.itemPosition]);
  80. this.setOnCallback(e.target.itemPosition);
  81. }.bind(this));
  82. }
  83. },
  84. //点了什么
  85. setOnCallback : function(count){
  86. if (count == 10) {
  87. dialogmanager.init(task.Canvas,function () {
  88. dialogmanager.creatorEnd();
  89. }.bind(this));
  90. dialogmanager.setOnCloseDialog(function () {
  91. }.bind(this));
  92. return;
  93. }
  94. // console.log("加了吗",count);
  95. task.addTaskTipsNoArr(this.node, this.helpPrefab[count], 0, 0, "videoTutorialCreatorBtn", function (nodePrefabs) {
  96. nodePrefabs.parent = this.node;
  97. if (count ==9 ) {
  98. task.addListView(nodePrefabs,function () {
  99. task.removeNode(nodePrefabs);
  100. }.bind(this));
  101. return;
  102. }
  103. if (count<this.arrbuttonHelp.length-1) {
  104. UtilsPrefabs.setOn(nodePrefabs.getChildByName("SureBtn"),function () {
  105. task.removeNode(nodePrefabs);
  106. }.bind(this))
  107. }
  108. }.bind(this));
  109. },
  110. onCallback : function(){
  111. UtilsPrefabs.setOff(this.up);
  112. UtilsPrefabs.setOff(this.down);
  113. UtilsPrefabs.setOn(this.up,function () {
  114. this.addCurr(false);
  115. }.bind(this));
  116. UtilsPrefabs.setOn(this.down,function () {
  117. this.addCurr(true);
  118. }.bind(this));
  119. },
  120. addCurr : function(b){
  121. // console.log("增加 减少",b,"当前索引",this.curr,"总长度是",this.listview.children.length);
  122. if (b) {
  123. if (this.curr < this.listview.children.length-1) {
  124. this.curr++;
  125. }
  126. }else{
  127. if (this.curr > 0) {
  128. this.curr--;
  129. }
  130. }
  131. for (var i = 0; i < this.listview.children.length; i++) {
  132. this.listview.children[i].active = false;
  133. }
  134. this.listview.children[this.curr].active = true;
  135. this.isShowButton();
  136. },
  137. isShowButton : function(){
  138. if (this.curr == 0) {
  139. this.up.active = false;
  140. this.down.active = true;
  141. }else if (this.curr == this.listview.children.length-1) {
  142. this.up.active = true;
  143. this.down.active = false;
  144. }else{
  145. this.up.active = true;
  146. this.down.active = true;
  147. }
  148. },
  149. start () {
  150. },
  151. // update (dt) {},
  152. });