Provides mouse event detection for FlxObject and FlxSprite (pixel-perfect for those). To use it, register objects / sprites with FlxMouseEvent.add():

var object = new FlxObject();
FlxMouseEvent.add(object, onMouseDown, onMouseUp, onMouseOver, onMouseOut);

Also implement the callbacks with the object's type as parameters:

function onMouseDown(object:FlxObject) {}
function onMouseUp(object:FlxObject) {}
function onMouseOver(object:FlxObject) {}
function onMouseOut(object:FlxObject) {}

FlxMouseEvent is meant to be the access point to the global FlxMouseEventManager instance.

Available since

5.0.0

.

See also:

Static variables

staticglobalManager:FlxMouseEventManager

The global FlxMouseEventManager instance to which FlxMouseEvent provides access.

Static methods

@:value({ pixelPerfect : true, mouseEnabled : true, mouseChildren : false })staticinlineadd<T>(object:T, ?onMouseDown:T ‑> Void, ?onMouseUp:T ‑> Void, ?onMouseOver:T ‑> Void, ?onMouseOut:T ‑> Void, mouseChildren:Bool = false, mouseEnabled:Bool = true, pixelPerfect:Bool = true, ?mouseButtons:Array<FlxMouseButtonID>):T

Adds an object to the FlxMouseEventManager registry. Automatically initializes the plugin.

Parameters:

onMouseDown

Callback when mouse is pressed down over this object. Must have Object as argument - e.g. onMouseDown(object:FlxObject).

onMouseUp

Callback when mouse is released over this object. Must have Object as argument - e.g. onMouseDown(object:FlxObject).

onMouseOver

Callback when mouse is this object. Must have Object as argument - e.g. onMouseDown(object:FlxObject).

onMouseOut

Callback when mouse moves out of this object. Must have Object as argument - e.g. onMouseDown(object:FlxObject).

mouseChildren

If true, other objects overlapped by this will still receive mouse events.

mouseEnabled

If true, this object will receive mouse events.

pixelPerfect

If true, the collision check will be pixel-perfect. Only works for FlxSprites.

mouseButtons

The mouse buttons that can trigger callbacks. Left only by default.

staticinlineisObjectMouseChildren<T>(object:T):Bool

Checks if an object allows mouseChildren.

staticinlineisObjectMouseEnabled<T>(object:T):Bool

Checks if a registered object is mouseEnabled.

staticinlineremove<T>(object:T):T

Removes a registered object from the registry.

staticinlineremoveAll():Void

Removes all registered objects from the registry.

staticinlinereorder():Void

Reorders the registered objects, using the current object drawing order. This should be called if you alter the draw/update order of a registered object, That is, if you alter the position of a registered object inside its FlxGroup. It may also be called if the objects are not registered by the same order they are added to FlxGroup.

staticinlinesetMouseClickCallback<T>(object:T, onMouseClick:T ‑> Void):Void

Sets the mouseClick callback associated with an object.

Parameters:

onMouseClick

Callback when mouse is pressed and released over this object. Must have Object as argument - e.g. onMouseClick(object:FlxObject).

Available since

4.4.0

.

staticinlinesetMouseDoubleClickCallback<T>(object:T, onMouseDoubleClick:T ‑> Void):Void

Sets the mouseDoubleClick callback associated with an object.

Parameters:

onMouseDoubleClick

Callback when mouse is pressed and released over this object twice. Must have Object as argument - e.g. onMouseDoubleClick(object:FlxObject).

Available since

4.4.0

.

staticinlinesetMouseDownCallback<T>(object:T, onMouseDown:T ‑> Void):Void

Sets the mouseDown callback associated with an object.

Parameters:

onMouseDown

Callback when mouse is pressed down over this object. Must have Object as argument - e.g. onMouseDown(object:FlxObject).

staticinlinesetMouseMoveCallback<T>(object:T, onMouseMove:T ‑> Void):Void

Sets the mouseMove callback associated with an object.

Parameters:

onMouseMove

Callback when the mouse is moved while over this object. Must have Object as argument - e.g. onMouseMove(object:FlxObject).

Available since

4.4.0

.

staticinlinesetMouseOutCallback<T>(object:T, onMouseOut:T ‑> Void):Void

Sets the mouseOut callback associated with an object.

Parameters:

OnMouseOver

Callback when mouse is moved out of this object. Must have Object as argument - e.g. onMouseDown(object:FlxObject).

staticinlinesetMouseOverCallback<T>(object:T, onMouseOver:T ‑> Void):Void

Sets the mouseOver callback associated with an object.

Parameters:

onMouseOver

Callback when mouse is over this object. Must have Object as argument - e.g. onMouseDown(object:FlxObject).

staticinlinesetMouseUpCallback<T>(object:T, onMouseUp:T ‑> Void):Void

Sets the mouseUp callback associated with an object.

Parameters:

onMouseUp

Callback when mouse is released over this object. Must have Object as argument - e.g. onMouseDown(object:FlxObject).

staticinlinesetMouseWheelCallback<T>(object:T, onMouseWheel:T ‑> Void):Void

Sets the mouseWheel callback associated with an object.

Parameters:

onMouseWheel

Callback when the mouse wheel is moved while over this object. Must have Object as argument - e.g. onMouseWheel(object:FlxObject).

Available since

4.4.0

.

staticinlinesetObjectMouseButtons<T>(object:T, mouseButtons:Array<FlxMouseButtonID>):Void

Parameters:

mouseButtons

The mouse buttons that can trigger callbacks. Left only by default.

staticinlinesetObjectMouseChildren<T>(object:T, mouseChildren:Bool):Void

Enables/disables mouseChildren for an object.

Parameters:

mouseChildren

Whether this object will allow other overlapping object to receive mouse events.

staticinlinesetObjectMouseEnabled<T>(object:T, mouseEnabled:Bool):Void

Enables/disables mouse behavior for an object.

Parameters:

mouseEnabled

Whether this object will be tested for mouse events.

Variables

Methods