Cocos Creator API

1.0.0

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

Component.EventHandler

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
1. var eventHandler = cc.Component.EventHandler(target, "MainMenu", "OnClick");
2. var eventHandler = cc.Component.EventHandler();
   eventHandler.target = newTarget;
   eventHandler.component = "MainMenu";
   eventHandler.handler = "OnClick"

Properties

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

Methods

emitEvents
(
  • events
  • params
)

name type description
events Component.EventHandler[]
params

emit
(
  • params
)

Emit event with params

name type description
params

examples:

// Call Function
var eventHandler = cc.Component.EventHandler(target, "MainMenu", "OnClick");
eventHandler.emit("This is the argument to the callback function!");

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