Cocos Creator API

1.3.0

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

EventListener

: cc

The base class of event listener.
If you need custom listener which with different callback, you need to inherit this class.
For instance, you could refer to EventListenerAcceleration, EventListenerKeyboard,
EventListenerTouchOneByOne, EventListenerCustom.

UNKNOWN Number static

The type code of unknown event listener.

KEYBOARD Number static

The type code of keyboard event listener.

ACCELERATION Number static

The type code of focus event listener.

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

EventListener
(
  • type
  • listenerID
  • callback
)
EventListener

Constructor

type Number
listenerID Number
callback Number

checkAvailable ( ) Boolean

Checks whether the listener is available.

:

clone ( ) EventListener

Clones the listener, its subclasses have to override this method.

setEnabled
(
  • enabled
)

Enables or disables the listener

enabled Boolean

isEnabled ( ) Boolean

Checks whether the listener is enabled

:

create
(
  • argObj
)
EventListener static

Create a EventListener object with configuration including the event type, handlers and other parameters. In handlers, this refer to the event listener object itself. You can also pass custom parameters in the configuration object, all custom parameters will be polyfilled into the event listener object and can be accessed in handlers.

argObj Object

a json object

:

// Create KEYBOARD EventListener.
cc.EventListener.create({
    event: cc.EventListener.KEYBOARD,
    onKeyPressed: function (keyCode, event) {
        cc.log('pressed key: ' + keyCode);
    },
    onKeyReleased: function (keyCode, event) {
        cc.log('released key: ' + keyCode);
    }
});

// Create ACCELERATION EventListener.
cc.EventListener.create({
    event: cc.EventListener.ACCELERATION,
    callback: function (acc, event) {
        cc.log('acc: ' + keyCode);
    }
});

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