Packageorg.flixel.system.input
Classpublic class Mouse
InheritanceMouse Inheritance FlxPoint Inheritance Object

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



Public Properties
 PropertyDefined By
  screenX : int
Current X position of the mouse pointer on the screen.
Mouse
  screenY : int
Current Y position of the mouse pointer on the screen.
Mouse
  visible : Boolean
[read-only] Read only, check visibility of mouse cursor.
Mouse
  wheel : int
Current "delta" value of mouse wheel.
Mouse
 Inheritedx : Number
FlxPoint
 Inheritedy : Number
FlxPoint
Protected Properties
 PropertyDefined By
  _current : int
Helper variable for tracking whether the mouse was just pressed or just released.
Mouse
  _cursor : Bitmap
This is just a reference to the current cursor image, if there is one.
Mouse
  _cursorContainer : Sprite
A display container for the mouse cursor.
Mouse
  _globalScreenPosition : FlxPoint
Mouse
  ImgDefaultCursor : Class
Mouse
  _last : int
Helper variable for tracking whether the mouse was just pressed or just released.
Mouse
  _lastWheel : int
Mouse
  _lastX : int
Helper variables for recording purposes.
Mouse
  _lastY : int
Mouse
  _point : FlxPoint
Mouse
Public Methods
 MethodDefined By
  
Mouse(CursorContainer:Sprite)
Constructor.
Mouse
 Inherited
Helper function, just copies the values from the specified point.
FlxPoint
 Inherited
copyFromFlash(FlashPoint:Point):FlxPoint
Helper function, just copies the values from the specified Flash point.
FlxPoint
 Inherited
Helper function, just copies the values from this point to the specified point.
FlxPoint
 Inherited
copyToFlash(FlashPoint:Point):Point
Helper function, just copies the values from this point to the specified Flash point.
FlxPoint
  
destroy():void
Clean up memory.
Mouse
  
getScreenPosition(Camera:FlxCamera = null, Point:FlxPoint = null):FlxPoint
Fetch the screen position of the mouse on any given camera.
Mouse
  
getWorldPosition(Camera:FlxCamera = null, Point:FlxPoint = null):FlxPoint
Fetch the world position of the mouse on any given camera.
Mouse
  
handleMouseDown(FlashEvent:MouseEvent):void
Event handler so FlxGame can update the mouse.
Mouse
  
handleMouseUp(FlashEvent:MouseEvent):void
Event handler so FlxGame can update the mouse.
Mouse
  
handleMouseWheel(FlashEvent:MouseEvent):void
Event handler so FlxGame can update the mouse.
Mouse
  
hide():void
Hides the mouse cursor
Mouse
  
justPressed():Boolean
Check to see if the mouse was just pressed.
Mouse
  
justReleased():Boolean
Check to see if the mouse was just released.
Mouse
  
load(Graphic:Class = null, Scale:Number = 1, XOffset:int = 0, YOffset:int = 0):void
Load a new mouse cursor graphic
Mouse
 Inherited
make(X:Number = 0, Y:Number = 0):FlxPoint
Instantiate a new point object.
FlxPoint
  
playback(Record:MouseRecord):void
Part of the keystroke recording system.
Mouse
  
pressed():Boolean
Check to see if the mouse is pressed.
Mouse
  
If the mouse changed state or is pressed, return that info now
Mouse
  
reset():void
Resets the just pressed/just released flags and sets mouse to not pressed.
Mouse
  
show(Graphic:Class = null, Scale:Number = 1, XOffset:int = 0, YOffset:int = 0):void
Either show an existing cursor or load a new one.
Mouse
  
unload():void
Unload the current cursor graphic.
Mouse
  
update(X:int, Y:int):void
Called by the internal game loop to update the mouse pointer's position in the game world.
Mouse
Protected Methods
 MethodDefined By
  
Internal function for helping to update the mouse cursor and world coordinates.
Mouse
Property Detail
_currentproperty
protected var _current:int

Helper variable for tracking whether the mouse was just pressed or just released.

_cursorproperty 
protected var _cursor:Bitmap

This is just a reference to the current cursor image, if there is one.

_cursorContainerproperty 
protected var _cursorContainer:Sprite

A display container for the mouse cursor. This container is a child of FlxGame and sits at the right "height".

_globalScreenPositionproperty 
protected var _globalScreenPosition:FlxPoint

_lastproperty 
protected var _last:int

Helper variable for tracking whether the mouse was just pressed or just released.

_lastWheelproperty 
protected var _lastWheel:int

_lastXproperty 
protected var _lastX:int

Helper variables for recording purposes.

_lastYproperty 
protected var _lastY:int

_pointproperty 
protected var _point:FlxPoint

ImgDefaultCursorproperty 
protected var ImgDefaultCursor:Class

screenXproperty 
public var screenX:int

Current X position of the mouse pointer on the screen.

screenYproperty 
public var screenY:int

Current Y position of the mouse pointer on the screen.

visibleproperty 
visible:Boolean  [read-only]

Read only, check visibility of mouse cursor.


Implementation
    public function get visible():Boolean
wheelproperty 
public var wheel:int

Current "delta" value of mouse wheel. If the wheel was just scrolled up, it will have a positive value. If it was just scrolled down, it will have a negative value. If it wasn't just scroll this frame, it will be 0.

Constructor Detail
Mouse()Constructor
public function Mouse(CursorContainer:Sprite)

Constructor.

Parameters
CursorContainer:Sprite
Method Detail
destroy()method
public function destroy():void

Clean up memory.

getScreenPosition()method 
public function getScreenPosition(Camera:FlxCamera = null, Point:FlxPoint = null):FlxPoint

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

Parameters

Camera:FlxCamera (default = null) — If unspecified, first/main global camera is used instead.
 
Point:FlxPoint (default = null) — An existing point object to store the results (if you don't want a new one created).

Returns
FlxPoint — The mouse's location in screen space.
getWorldPosition()method 
public function getWorldPosition(Camera:FlxCamera = null, Point:FlxPoint = null):FlxPoint

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

Parameters

Camera:FlxCamera (default = null) — If unspecified, first/main global camera is used instead.
 
Point:FlxPoint (default = null) — An existing point object to store the results (if you don't want a new one created).

Returns
FlxPoint — The mouse's location in world space.
handleMouseDown()method 
public function handleMouseDown(FlashEvent:MouseEvent):void

Event handler so FlxGame can update the mouse.

Parameters

FlashEvent:MouseEvent — A MouseEvent object.

handleMouseUp()method 
public function handleMouseUp(FlashEvent:MouseEvent):void

Event handler so FlxGame can update the mouse.

Parameters

FlashEvent:MouseEvent — A MouseEvent object.

handleMouseWheel()method 
public function handleMouseWheel(FlashEvent:MouseEvent):void

Event handler so FlxGame can update the mouse.

Parameters

FlashEvent:MouseEvent — A MouseEvent object.

hide()method 
public function hide():void

Hides the mouse cursor

justPressed()method 
public function justPressed():Boolean

Check to see if the mouse was just pressed.

Returns
Boolean — Whether the mouse was just pressed.
justReleased()method 
public function justReleased():Boolean

Check to see if the mouse was just released.

Returns
Boolean — Whether the mouse was just released.
load()method 
public function load(Graphic:Class = null, Scale:Number = 1, XOffset:int = 0, YOffset:int = 0):void

Load a new mouse cursor graphic

Parameters

Graphic:Class (default = null) — The image you want to use for the cursor.
 
Scale:Number (default = 1) — Change the size of the cursor.
 
XOffset:int (default = 0) — The number of pixels between the mouse's screen position and the graphic's top left corner.
 
YOffset:int (default = 0) — The number of pixels between the mouse's screen position and the graphic's top left corner.

playback()method 
public function playback(Record:MouseRecord):void

Part of the keystroke recording system. Takes data about key presses and sets it into array.

Parameters

Record:MouseRecord — Array of data about key states.

pressed()method 
public function pressed():Boolean

Check to see if the mouse is pressed.

Returns
Boolean — Whether the mouse is pressed.
record()method 
public function record():MouseRecord

If the mouse changed state or is pressed, return that info now

Returns
MouseRecord — An array of key state data. Null if there is no data.
reset()method 
public function reset():void

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

show()method 
public function show(Graphic:Class = null, Scale:Number = 1, XOffset:int = 0, YOffset:int = 0):void

Either show an existing cursor or load a new one.

Parameters

Graphic:Class (default = null) — The image you want to use for the cursor.
 
Scale:Number (default = 1) — Change the size of the cursor. Default = 1, or native size. 2 = 2x as big, 0.5 = half size, etc.
 
XOffset:int (default = 0) — The number of pixels between the mouse's screen position and the graphic's top left corner.
 
YOffset:int (default = 0) — The number of pixels between the mouse's screen position and the graphic's top left corner.

unload()method 
public function 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.

update()method 
public function update(X:int, Y:int):void

Called by the internal game loop to update the mouse pointer's position in the game world. Also updates the just pressed/just released flags.

Parameters

X:int — The current X position of the mouse in the window.
 
Y:int — The current Y position of the mouse in the window.

updateCursor()method 
protected function updateCursor():void

Internal function for helping to update the mouse cursor and world coordinates.