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.

      Regions under the pointer are asked in the order they are drawn, topmost first, and the walk continues downwards until a callback returns false. Depth is resolved per container, so a child's pos.z orders it among its siblings only and a cross-container pair is decided at the common ancestor, matching what is drawn on top. app.viewport is asked BEFORE all of them rather than as a fallback, so a callback registered on it should not return false unless it means to swallow every pointer event in the game.

      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: (pointer: Pointer) => boolean | void

        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

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