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
Variables
maxDoubleClickDelay:Int = 500
The maximum amount of time between two clicks that is considered a double click, in milliseconds.
4.4.0
.Methods
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. |
---|---|
onMouseUp | Callback when mouse is released over this object.
Must have Object as argument - e.g. |
onMouseOver | Callback when mouse is this object.
Must have Object as argument - e.g. |
onMouseOut | Callback when mouse moves out of this object.
Must have Object as argument - e.g. |
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. |
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. |
---|
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. |
---|
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. |
---|
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. |
---|
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. |
---|
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. |
---|
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. |
---|
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. |
---|
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. |
---|