Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface ClickListener

Every Screen interested in click events must implement this interface (Except when DELEGATE mode is used). Click event listener must be activated in Engine :

// Not interested in clicked sprites
engine.enableMouseControl(); // Equivalent to engine.enableMouseControl(MouseEventType.BASIC);

It's possible to capture the list of sprites clicked by setting the optional argument to true

// Capture sprites
engine.enableMouseControl(MouseEventType.SPRITES);

Sprites may also manage their behaviour themselves

// Capture sprites
engine.enableMouseControl(MouseEventType.DELEGATE);

When MouseEventType.DELEGATE is used, Screen needn't implement ClickListener interface To enforce declaration of interface, use MouseEventType.DELEGATE_STRICT. Screen declaration of onClick is called BEFORE any sprite, can cancel delegation by returning false.

Hierarchy

  • ClickListener

Index

Methods

Methods

onClick

  • Called when a user clicks on the screen

    Parameters

    • engine: Engine

      A reference to the active engine

    • point: Point

      The position of the click

    • sprites: Array<Sprite<any>>

      The list of sprites under the click, if capture is enabled

    Returns boolean

    true if Sprite.onClick method should be called in DELEGATE mode

Generated using TypeDoc