This class helps contain and track the mouse pointer in your game. Automatically accounts for parallax scrolling, etc. Normally accessed via FlxG.mouse.

Variables

read onlycursor:Null<Bitmap>

The current cursor bitmap, if there is one. To set, use the load function.

read onlycursorContainer:Sprite

A display container for the mouse cursor. It is a child of FlxGame and sits at the right "height". Not used on flash with the native cursor API.

read onlydeltaScreenX:Int

Distance in pixels the mouse has moved in screen space since the last frame in the X direction.

read onlydeltaScreenY:Int

Distance in pixels the mouse has moved in screen space since the last frame in the Y direction.

read onlydeltaX:Int

Distance in pixels the mouse has moved since the last frame in the X direction.

read onlydeltaY:Int

Distance in pixels the mouse has moved since the last frame in the Y direction.

@:value(true)enabled:Bool = true

Whether or not mouse input is currently enabled.

Available since

4.1.0

.

read onlyjustMoved:Bool

Check to see if the mouse has just been moved.

Available since

4.4.0

.

read onlyjustPressed:Bool

Check to see if the left mouse button has just been pressed.

read onlyjustPressedMiddle:Bool

Check to see if the middle mouse button has just been pressed.

read onlyjustPressedRight:Bool

Check to see if the right mouse button has just been pressed.

read onlyjustPressedTimeInTicks:Int

Time in ticks of last left mouse button press.

Available since

4.3.0

.

read onlyjustPressedTimeInTicksMiddle:Int

Time in ticks of last middle mouse button press.

Available since

4.3.0

.

read onlyjustPressedTimeInTicksRight:Int

Time in ticks of last right mouse button press.

Available since

4.3.0

.

read onlyjustReleased:Bool

Check to see if the left mouse button has just been released.

read onlyjustReleasedMiddle:Bool

Check to see if the middle mouse button has just been released.

read onlyjustReleasedRight:Bool

Check to see if the right mouse button has just been released.

read onlypressed:Bool

Check to see if the left mouse button is currently pressed.

read onlypressedMiddle:Bool

Check to see if the middle mouse button is currently pressed.

read onlypressedRight:Bool

Check to see if the right mouse button is currently pressed.

read onlyreleased:Bool

Check to see if the left mouse button is currently not pressed.

Available since

5.0.0

.

read onlyreleasedMiddle:Bool

Check to see if the middle mouse button is currently not pressed.

Available since

5.0.0

.

read onlyreleasedRight:Bool

Check to see if the right mouse button is currently not pressed.

Available since

5.0.0

.

@:value(false)useSystemCursor:Bool = false

Tells flixel to use the default system mouse cursor instead of custom Flixel mouse cursors.

@:value(true)visible:Bool = true

Used to toggle the visiblity of the mouse cursor - works on both the flixel and the system cursor, depending on which one is active.

@:value(0)read onlywheel:Int = 0

Current "delta" value of mouse wheel. If the wheel was just scrolled up, it will have a positive value and vice versa. Otherwise the value will be 0.

Methods

@:value({ YOffset : 0, XOffset : 0, Scale : 1 })load(?Graphic:Dynamic, Scale:Float = 1, XOffset:Int = 0, YOffset:Int = 0):Void

Load a new mouse cursor graphic - if you're using native cursors on flash, check registerNativeCursor() for more control.

Parameters:

Graphic

The image you want to use for the cursor.

Scale

Change the size of the cursor.

XOffset

The number of pixels between the mouse's screen position and the graphic's top left corner. Has to be positive when using native cursors.

YOffset

The number of pixels between the mouse's screen position and the graphic's top left corner. Has to be positive when using native cursors.

@:has_untypedinlineregisterNativeCursor(name:String, cursorData:MouseCursorData):Void

Shortcut to register a native cursor in flash

Parameters:

name

The ID name used for the cursor

cursorData

MouseCursorData contains the bitmap, hotspot etc

registerSimpleNativeCursorData(name:String, cursorBitmap:BitmapData):MouseCursorData

Shortcut to register a simple MouseCursorData

Parameters:

name

The ID name used for the cursor

cursorData

MouseCursorData contains the bitmap, hotspot etc

Available since

4.2.0

.

reset():Void

Resets the just pressed/just released flags and sets mouse to not pressed.

setNativeCursor(name:String):Void

Set a Native cursor that has been registered by name Warning, you need to use registerNativeCursor() before you use it here

Parameters:

name

The name ID used when registered

setSimpleNativeCursorData(name:String, cursorBitmap:BitmapData):MouseCursorData

Shortcut to create and set a simple MouseCursorData

Parameters:

name

The ID name used for the cursor

cursorData

MouseCursorData contains the bitmap, hotspot etc

unload():Void

Unload the current cursor graphic. If the current cursor is visible, then the default system cursor is loaded up to replace the old one.

Inherited Variables

Defined by FlxPointer

@:value(0)read onlyscreenX:Int = 0

@:value(0)read onlyscreenY:Int = 0

@:value(0)read onlyx:Int = 0

@:value(0)read onlyy:Int = 0

Inherited Methods

Defined by FlxPointer

getPosition(?point:FlxPoint):FlxPoint

Returns a FlxPoint with this input's x and y.

@:access(flixel.FlxCamera)getPositionInCameraView(?Camera:FlxCamera, ?point:FlxPoint):FlxPoint

Fetch the screen position of the pointer relative to given camera's viewport.

Parameters:

Camera

If unspecified, first/main global camera is used instead.

point

An existing point object to store the results (if you don't want a new one created).

Returns:

The touch point's location relative to camera's viewport.

getScreenPosition(?Camera:FlxCamera, ?point:FlxPoint):FlxPoint

Fetch the screen position of the pointer on any given camera. NOTE: screenX and screenY also store the screen position of the pointer on the main camera.

Parameters:

Camera

If unspecified, first/main global camera is used instead.

point

An existing point object to store the results (if you don't want a new one created).

Returns:

The touch point's location in screen space.

getWorldPosition(?Camera:FlxCamera, ?point:FlxPoint):FlxPoint

Fetch the world position of the pointer on any given camera. NOTE: x and y also store the world position of the pointer on the main camera.

Parameters:

Camera

If unspecified, first/main global camera is used instead.

point

An existing point object to store the results (if you don't want a new one created).

Returns:

The touch point's location in world space.

@:access(flixel.group.FlxTypedGroup.resolveGroup)overlaps(ObjectOrGroup:FlxBasic, ?Camera:FlxCamera):Bool

Checks to see if some FlxObject overlaps this FlxObject or FlxGroup. If the group has a LOT of things in it, it might be faster to use FlxG.overlaps(). WARNING: Currently tilemaps do NOT support screen space overlap checks!

Parameters:

ObjectOrGroup

The object or group being tested.

Camera

Specify which game camera you want. If null getScreenPosition() will just grab the first global camera.

Returns:

Whether or not the two objects overlap.

inlinesetGlobalScreenPositionUnsafe(newX:Float, newY:Float):Void

Directly set the underyling screen position variable. WARNING! You should never use this unless you are trying to manually dispatch low-level mouse / touch events to the stage.