12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- var gameHelp = cc.Class({
- extends: cc.Component,
- properties: {
- btn: {
- title: "按钮",
- type: cc.Node,
- default:[],
- },
- btnCallFunc: null,
- isClose:true,
- },
- // LIFE-CYCLE CALLBACKS:
- setParam(param){
- this.isClose = param;
- cc.log("param", param);
- },
- onLoad() {
- this.node.on(cc.Node.EventType.TOUCH_START, this.touchBegin.bind(this), this);
- if (!Module.GameHelpLayer) Module.GameHelpLayer = this;
- for (var i in this.btn){
- this.btn[i].on('click', function (event) {
- this.node.destroy();
- Module.GameHelpLayer = null;
- console.log("------click", event.node.name);
- if (this.btnCallFunc) this.btnCallFunc(event.node.name);
- }.bind(this));
- }
- },
- start() {
- },
- call: function (func) {
- this.btnCallFunc = func;
- },
- touchBegin: function (touch, event) {
- if (!this.isClose) return;
- this.node.destroy();
- },
- // update (dt) {},
- });
|