class flixel.plugin.MouseEventManager extends FlxPlugin

Available on all platforms

Provides mouse event detection for FlxObjects and FlxSprites (pixel-perfect for those). * To use it, initialize the manager and register objects / sprites. * * FlxG.plugins.add(new MouseEventManager()); * var object = new FlxObject(); * MouseEventManager.add(object, onMouseDown, onMouseUp, onMouseOver, onMouseOut); * * Or simply add a new object and this plugin will initialize itself: * * MouseEventManager.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) {} * * @author TiagoLr (~~~ ProG4mr ~~~)

Class Fields

static function add<T>(Object:T, ?OnMouseDown:T ->Void = null, ?OnMouseUp:T ->Void = null, ?OnMouseOver:T ->Void = null, ?OnMouseOut:T ->Void = null, ?MouseChildren:Bool = false, ?MouseEnabled:Bool = true, ?PixelPerfect:Bool = true):T

Adds an object to the MouseEventManager registry. Automatically initializes the plugin. * *

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 mouseChildren is enabled, other objects overlaped by this will still receive mouse events. *

MouseEnabled

If mouseEnabled this object will receive mouse events. *

PixelPerfect

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

static function init():Void

As alternative you can call MouseEventManager.init().

static function isObjectMouseChildren<T>(Object:T):Bool

Checks if an object allows mouseChildren.

static function isObjectMouseEnabled<T>(Object:T):Bool

Checks if a registered object is mouseEnabled.

static function remove<T>(Object:T):T

Removes a sprite from the registry.

static function 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.

static function setMouseDownCallback<T>(Object:T, OnMouseDown:T ->Void):Void

Sets the mouseDown callback associated with an object. * *

OnMouseDown

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

static function setMouseOutCallback<T>(Object:T, OnMouseOut:T ->Void):Void

Sets the mouseOut callback associated with an object. * *

OnMouseOver

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

static function setMouseOverCallback<T>(Object:T, OnMouseOver:T ->Void):Void

Sets the mouseOver callback associated with an object. * *

OnMouseOver

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

static function setMouseUpCallback<T>(Object:T, OnMouseUp:T ->Void):Void

Sets the mouseUp callback associated with an object. * *

OnMouseUp

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

static function setObjectMouseChildren<T>(Object:T, MouseChildren:Bool):Void

Enables/disables mouseChildren for an object. * *

MouseChildren

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

static function setObjectMouseEnabled<T>(Object:T, MouseEnabled:Bool):Void

Enables/disables mouse behavior for an object. * *

MouseEnabled

Whether this object will be tested for mouse events.

Instance Fields

function new():Void

function destroy():Void

function update():Void