Cocos Creator API

1.3.0

Cocos Creator is a highly customizable game development tool that utilizes the power of cocos2d-x.

Component.EventHandler

: cc

Component will register a event to target component's handler. And it will trigger the handler when a certain event occurs.

!@zh “EventHandler” 类用来设置场景中的事件回调, 该类允许用户设置回调目标节点,目标组件名,组件方法名, 并可通过 emit 方法调用目标函数。

:

// Create new EventHandler
var eventHandler = new cc.Component.EventHandler();
eventHandler.target = newTarget;
eventHandler.component = "MainMenu";
eventHandler.handler = "OnClick"

target Node

Event target

component String

Component name

handler String

Event handler

There are no properties that match your current filter settings. You can change your filter settings in the index section on this page. index

emitEvents
(
  • events
  • params
)

events Component.EventHandler[]
params Any

emit
(
  • params
)

Emit event with params

params Array

:

// Call Function
var eventHandler = new cc.Component.EventHandler();
eventHandler.target = newTarget;
eventHandler.component = "MainMenu";
eventHandler.handler = "OnClick"
eventHandler.emit(["param1", "param2", ....]);

There are no methods that match your current filter settings. You can change your filter settings in the index section on this page. index