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;
  },
See:
Parameters:
Name Type Description
eventType string

The event type for which the object is registering
melonJS currently supports:

  • "pointermove"
  • "pointerdown"
  • "pointerup"
  • "pointerenter"
  • "pointerover"
  • "pointerleave"
  • "pointercancel"
  • "wheel"
region Rect | Polygon | Line | Ellipse

a shape representing the region to register on

callback Function

methods to be called when the event occurs. Returning false from the defined callback will prevent the event to be propagated to other objects

Returns:
Type Description
Powered by webdoc!