代码改变世界

获取Button脚本挂载的事件名

2018-09-30 18:43  罗任德  阅读(645)  评论(0编辑  收藏  举报

(function(){
var Super = function(){};
Super.prototype = cc.Button.prototype;
//实例化原型
Super.prototype._onTouchEnded = function (t) {
if (this.interactable && this.enabledInHierarchy) {
var callback = t.currentTarget._bubblingListeners._callbackTable.touchend.targets[0].clickEvents.length;
if(callback != 0){
cc.hb.audioMgr.playEffect("click", false);//播放Button音效
}
//t.currentTarget._bubblingListeners._callbackTable.touchend.targets[0].clickEvents[0].handler//获取Button脚本挂载的事件名
if (this._pressed) {
cc.Component.EventHandler.emitEvents(this.clickEvents, t);
this.node.emit("click", this);
}
this._pressed = !1;
this._updateState();
t.stopPropagation();
}
};
})();