Methods
off
- off(type: string, callback?: undefined | ((...any: any[]) => void), target?: any): void
-
Parameters
-
type: string
-
Optional callback: undefined | ((...any: any[]) => void)
-
Optional target: any
Returns void
on
-
Parameters
-
-
callback: (event: EventKeyboard) => void
-
Optional target: unknown
Returns typeof callback
-
Parameters
-
-
callback: (event: EventMouse) => void
-
Optional target: unknown
Returns typeof callback
-
Parameters
-
-
callback: (touch: Touch, event: EventTouch) => void
-
Optional target: unknown
Returns typeof callback
-
Parameters
Returns typeof callback
setAccelerometerEnabled
- setAccelerometerEnabled(isEnabled: boolean): void
setAccelerometerInterval
- setAccelerometerInterval(interval: number): void
系统事件,它目前支持按键事件和重力感应事件。
你可以通过
systemEvent
获取到SystemEvent
的实例。import { systemEvent, SystemEvent } from 'cc'; systemEvent.on(SystemEvent.EventType.DEVICEMOTION, this.onDeviceMotionEvent, this); systemEvent.off(SystemEvent.EventType.DEVICEMOTION, this.onDeviceMotionEvent, this);