Trigger an event directly with the event name and necessary arguments.
event type
Checks whether there is correspond event listener registered on the given event.
Event type.
Callback function when event triggered.
Callback callee.
Removes the listeners previously registered with the same type, callback, target and or useCapture, if only type is passed as parameter, all listeners registered with that type will be removed.
A string representing the event type being removed.
The callback to remove.
The target (this object) to invoke the callback, if it's not given, only callback without target will be removed
Register an callback of a specific system event type.
The event type
The event listener's callback
The event listener's target and callee
Register an callback of a specific event type on the EventTarget, the callback will remove itself after the first time it is triggered.
A string representing the event type to listen for.
The callback that will be invoked when the event is dispatched. The callback is ignored if it is a duplicate (the callbacks are unique).
Removes all callbacks registered in a certain event type or all callbacks registered with a certain target
The event type or target with which the listeners will be removed
Sets whether to enable the accelerometer event listener or not.
Sets the accelerometer interval value.
Removes all callbacks previously registered with the same target (passed as parameter). This is not for removing all listeners in the current event target, and this is not for removing all listeners the target parameter have registered. It's only for removing all listeners (callback and target couple) registered on the current event target by the target parameter.
The target to be searched for all related listeners
Generated using TypeDoc
The System event, it currently supports keyboard events and accelerometer events.
You can get the
SystemEvent
instance withsystemEvent
.import { systemEvent, SystemEvent } from 'cc'; systemEvent.on(SystemEvent.EventType.DEVICEMOTION, this.onDeviceMotionEvent, this); systemEvent.off(SystemEvent.EventType.DEVICEMOTION, this.onDeviceMotionEvent, this);