Component.EventHandler Class

Module: 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 方法调用目标函数。

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

Index

Properties
Methods

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:82
customEventData

Custom Event Data

meta description
Type String
Defined in cocos2d/core/components/CCComponentEventHandler.js:93

Methods

emitEvents
meta description
Defined in cocos2d/core/components/CCComponentEventHandler.js:106
Parameters
emit

Emit event with params

meta description
Defined in cocos2d/core/components/CCComponentEventHandler.js:130
Parameters
Examples
// Call Function
var eventHandler = new cc.Component.EventHandler();
eventHandler.target = newTarget;
eventHandler.component = "MainMenu";
eventHandler.handler = "OnClick"
eventHandler.emit(["param1", "param2", ....]);

results matching ""

    No results matching ""