Component.EventHandler
Class
Component will register a event to target component's handler. And it will trigger the handler when a certain event occurs.
!@zh “EventHandler” 类用来设置场景中的事件回调, 该类允许用户设置回调目标节点,目标组件名,组件方法名, 并可通过 emit 方法调用目标函数。
Index
Properties
target
Node
Event targetcomponent
String
Component namehandler
String
Event handlercustomEventData
String
Custom Event Data
Methods
emitEvents
emit
Emit event with params
Details
Properties
target
Event target
meta | description |
---|---|
Type | Node |
Defined in | cocos2d/core/components/CCComponentEventHandler.js:51 |
component
Component name
meta | description |
---|---|
Type | String |
Defined in | cocos2d/core/components/CCComponentEventHandler.js:62 |
handler
Event handler
meta | description |
---|---|
Type | String |
Defined in | cocos2d/core/components/CCComponentEventHandler.js:72 |
customEventData
Custom Event Data
meta | description |
---|---|
Type | String |
Defined in | cocos2d/core/components/CCComponentEventHandler.js:83 |
Methods
emitEvents
meta | description |
---|---|
Defined in | cocos2d/core/components/CCComponentEventHandler.js:96 |
Parameters
events
Component.EventHandler[]params
Any
emit
Emit event with params
meta | description |
---|---|
Defined in | cocos2d/core/components/CCComponentEventHandler.js:120 |
Parameters
params
Array
Examples
// Call Function
var eventHandler = new cc.Component.EventHandler();
eventHandler.target = newTarget;
eventHandler.component = "MainMenu";
eventHandler.handler = "OnClick"
eventHandler.emit(["param1", "param2", ....]);