input.registerPointerEvent
registerPointerEvent(eventType: string, region: Rect | Polygon | Line | Ellipse, callback: Function) → {}
allows registration of event listeners on the object target.
melonJS will pass a me.Pointer object to the defined callback.
// onActivate function
onActivateEvent: function () {
// register on the 'pointerdown' event
me.input.registerPointerEvent('pointerdown', this, (e) => this.pointerDown(e));
},
// pointerDown event callback
pointerDown: function (pointer) {
// do something
....
// don"t propagate the event to other objects
return false;
},
Name | Type | Description |
---|---|---|
eventType | string |
The event type for which the object is registering
|
region | Rect | Polygon | Line | Ellipse |
a shape representing the region to register on |
callback | Function |
methods to be called when the event occurs.
Returning |
Type | Description |
---|