tip.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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. window.tip = {}
  11. cc.Class({
  12. extends: cc.Component,
  13. properties: {
  14. // foo: {
  15. // // ATTRIBUTES:
  16. // default: null, // The default value will be used only when the component attaching
  17. // // to a node for the first time
  18. // type: cc.SpriteFrame, // optional, default is typeof default
  19. // serializable: true, // optional, default is true
  20. // },
  21. // bar: {
  22. // get () {
  23. // return this._bar;
  24. // },
  25. // set (value) {
  26. // this._bar = value;
  27. // }
  28. // },
  29. },
  30. // LIFE-CYCLE CALLBACKS:
  31. onLoad () {
  32. this.task = 0;
  33. this.tiplayout = UtilsNode.getNode("tiplayout",this.node)
  34. this.tiptext = UtilsNode.getNode("tiptext",this.tiplayout)
  35. this.tiplayoutc = this.tiplayout.getComponent("tiplayout")
  36. this.tiptextc = this.tiptext.getComponent(cc.Label)
  37. tip = this;
  38. this.skip = UtilsNode.getNode("skip",this.node)
  39. this.skiptext = UtilsNode.getNode("skiptext",this.skip)
  40. this.tipend = UtilsNode.getNode("tipend",this.node)
  41. this.tipendc = this.tipend.getComponent("tipend")
  42. this.initTask();
  43. this.initClick();
  44. this.initListen();
  45. this.initTipText();
  46. },
  47. initTipText(){
  48. if (this.tasks[this.task]) {
  49. this.tiptextc.string = this.tasks[this.task]
  50. }
  51. },
  52. initTask(){
  53. this.tasks = [
  54. //0
  55. "欢迎来到打地鼠游戏接下来介绍一下游戏玩法!",
  56. //1
  57. "首先有三个洞这里面会出现地鼠我们尝试着打一下吧",
  58. //2
  59. "击打拳击球方向左侧",
  60. //3
  61. "击打拳击球方向中间",
  62. //4
  63. "击打拳击球方向右侧",
  64. //5
  65. "注意这是炸弹击打之后会让所有地鼠消失",
  66. //6
  67. "这里是倒计时当时间用尽游戏结束",
  68. //7
  69. "这是记录击打地鼠的分数连击越高分数越高",
  70. ];
  71. },
  72. start () {
  73. },
  74. initClick (){
  75. UtilsNode.setOn(this.skiptext,function () {
  76. Log.info("点了跳过教程")
  77. utils.toLoadScene("game");
  78. }.bind(this))
  79. },
  80. initListen(){
  81. this.tiplayoutc.setCallOutListen(function () {
  82. this.task++;
  83. if (this.TaskChangeLishen) {
  84. this.TaskChangeLishen(this.task);
  85. }
  86. // this.initTipText();
  87. if (this.tasks[this.task]){
  88. this.tiplayoutc.playIn();
  89. }
  90. }.bind(this))
  91. this.tiplayoutc.setCallInListen(function () {
  92. this.initTipText();
  93. }.bind(this))
  94. },
  95. setTaskChangeLishen(TaskChangeLishen){
  96. this.TaskChangeLishen = TaskChangeLishen;
  97. }
  98. // update (dt) {},
  99. });