HelpNode.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. var gameHelp = cc.Class({
  2. extends: cc.Component,
  3. properties: {
  4. btn: {
  5. title: "按钮",
  6. type: cc.Node,
  7. default:[],
  8. },
  9. btnCallFunc: null,
  10. isClose:true,
  11. },
  12. // LIFE-CYCLE CALLBACKS:
  13. setParam(param){
  14. this.isClose = param;
  15. cc.log("param", param);
  16. },
  17. onLoad() {
  18. this.node.on(cc.Node.EventType.TOUCH_START, this.touchBegin.bind(this), this);
  19. if (!Module.GameHelpLayer) Module.GameHelpLayer = this;
  20. for (var i in this.btn){
  21. this.btn[i].on('click', function (event) {
  22. this.node.destroy();
  23. Module.GameHelpLayer = null;
  24. console.log("------click", event.node.name);
  25. if (this.btnCallFunc) this.btnCallFunc(event.node.name);
  26. }.bind(this));
  27. }
  28. },
  29. start() {
  30. },
  31. call: function (func) {
  32. this.btnCallFunc = func;
  33. },
  34. touchBegin: function (touch, event) {
  35. if (!this.isClose) return;
  36. this.node.destroy();
  37. },
  38. // update (dt) {},
  39. });