cocos creator的自定义事件

    var testEvent= new cc.Event.EventCustom("CustomName", false)
    testEvent.setUserData("abc")
    cc.find("UIScript").dispatchEvent(testEvent);
  • 1
  • 2
  • 3

cc.find(“UIScript”) 里 UIScript 是节点

    var that = this
     this.node.on("CustomName", function (event) {
         var data = event.getUserData() 
         cc.log("已经获得",data)
    }); 

你可能感兴趣的:(cocos creator的自定义事件)