Provides mouse event detection for FlxObject and FlxSprite (pixel-perfect for those). Normally you would use FlxMouseEvent static properties for this.

You can make a new FlxMouseEventManager instance for private usage, but you should know what you are doing.

See also:

Constructor

new()

Variables

@:value(500)maxDoubleClickDelay:Int = 500

The maximum amount of time between two clicks that is considered a double click, in milliseconds.

Available since

4.4.0

.

Methods

@:value({ pixelPerfect : true, mouseEnabled : true, mouseChildren : false })add<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.

isObjectMouseChildren<T>(object:T):Bool

Checks if an object allows mouseChildren.

isObjectMouseEnabled<T>(object:T):Bool

Checks if a registered object is mouseEnabled.

remove<T>(object:T):T

Removes a registered object from the registry.

removeAll():Void

Removes all registered objects from the registry.

reorder():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.

setMouseClickCallback<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

.

setMouseDoubleClickCallback<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

.

setMouseDownCallback<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).

setMouseMoveCallback<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

.

setMouseOutCallback<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).

setMouseOverCallback<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).

setMouseUpCallback<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).

setMouseWheelCallback<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

.

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

Parameters:

MouseButtons

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

setObjectMouseChildren<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.

setObjectMouseEnabled<T>(object:T, MouseEnabled:Bool):Void

Enables/disables mouse behavior for an object.

Parameters:

MouseEnabled

Whether this object will be tested for mouse events.

Inherited Variables

Defined by FlxBasic

@:value(idEnumerator++)ID:Int = idEnumerator++

A unique ID starting from 0 and increasing by 1 for each subsequent FlxBasic that is created.

@:value(true)active:Bool = true

Controls whether update() is automatically called by FlxState/FlxGroup.

@:value(true)alive:Bool = true

Useful state for many game objects - "dead" (!alive) vs alive. kill() and revive() both flip this switch (along with exists, but you can override that).

camera:FlxCamera

Gets or sets the first camera of this object.

cameras:Array<FlxCamera>

This determines on which FlxCameras this object will be drawn. If it is null / has not been set, it uses the list of default draw targets, which is controlled via FlxG.camera.setDefaultDrawTarget as well as the DefaultDrawTarget argument of FlxG.camera.add.

read onlycontainer:Null<FlxContainer>

The parent containing this basic, typically if you check this recursively you should reach the state

Available since

5.7.0

.

@:value(true)exists:Bool = true

Controls whether update() and draw() are automatically called by FlxState/FlxGroup.

@:value(true)visible:Bool = true

Controls whether draw() is automatically called by FlxState/FlxGroup.

Inherited Methods

Defined by FlxBasic

draw():Void

Override this function to control how the object is drawn. Doing so is rarely necessary, but can be very useful.

getCameras():Array<FlxCamera>

The cameras that will draw this. Use this.cameras to set specific cameras for this object, otherwise the container's cameras are used, or the container's container and so on. If there is no container, say, if this is inside FlxGroups rather than a FlxContainer then the default draw cameras are returned.

Available since

5.7.0

.

kill():Void

Handy function for "killing" game objects. Use reset() to revive them. Default behavior is to flag them as nonexistent AND dead. However, if you want the "corpse" to remain in the game, like to animate an effect or whatever, you should override this, setting only alive to false, and leaving exists true.

revive():Void

Handy function for bringing game objects "back to life". Just sets alive and exists back to true. In practice, this function is most often called by FlxObject#reset().