[Cocos Creator] How To use cc.Event.EventCustom

Hi all,
I’m a newbie, i have a problem

  • i have a file GamePlay.js:

cc.Class({extends: cc.Component,

 start () {
      this.node.on('custom_event',function(event){
          cc.log('==============this is custom event');
      });
  },

});

and file Hero.js

cc.Class({ extends: cc.Component,

 update: function (dt) {
       var Custom_Event = new cc.Event.EventCustom('custom_event', true);
       this.node.dispatchEvent(Custom_Event);
  }, 

});

but in gameplay.js can’t recieve event,
who can help me, thanks.

You have to listen on the object that emits the event. On GamePlay you do something like

start () {
      this.heroGameObject.node.on('custom_event',function(event){
          cc.log('==============this is custom event');
      });
  },