melonjs
    Preparing search index...

    Function registerPointerEvent

    • allows registration of event listeners on the object target.
      melonJS will pass a me.Pointer object to the defined callback.

      Parameters

      • eventType: string

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

        • "pointermove"
        • "pointerdown"
        • "pointerup"
        • "pointerenter"
        • "pointerover"
        • "pointerleave"
        • "pointercancel"
        • "wheel"
      • region: any

        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 void

      input

      // 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;
      },