Packageorg.flixel
Classpublic class FlxObject
InheritanceFlxObject Inheritance FlxBasic Inheritance Object
Subclasses FlxSprite, FlxTile, FlxTilemap

This is the base class for most of the display objects (FlxSprite, FlxText, etc). It includes some basic attributes about game objects, including retro-style flickering, basic state information, sizes, scrolling, and basic physics and motion.



Public Properties
 PropertyDefined By
  acceleration : FlxPoint
How fast the speed of this object is changing.
FlxObject
 Inheritedactive : Boolean
Controls whether update() is automatically called by FlxState/FlxGroup.
FlxBasic
 Inherited_ACTIVECOUNT : uint
[static]
FlxBasic
 Inheritedalive : Boolean
Useful state for many game objects - "dead" (!alive) vs alive.
FlxBasic
  allowCollisions : uint
Bit field of flags (use with UP, DOWN, LEFT, RIGHT, etc) indicating collision directions.
FlxObject
  angle : Number
Set the angle of a sprite to rotate it.
FlxObject
  angularAcceleration : Number
How fast the spin speed should change.
FlxObject
  angularDrag : Number
Like drag but for spinning.
FlxObject
  angularVelocity : Number
This is how fast you want this sprite to spin.
FlxObject
  drag : FlxPoint
This isn't drag exactly, more like deceleration that is only applied when acceleration is not affecting the sprite.
FlxObject
  elasticity : Number
FlxObject
 Inheritedexists : Boolean
Controls whether update() and draw() are automatically called by FlxState/FlxGroup.
FlxBasic
  flickering : Boolean
[read-only] Check to see if the object is still flickering.
FlxObject
  health : Number
Handy for storing health percentage or armor points or whatever.
FlxObject
  height : Number
FlxObject
 InheritedID : int
IDs seem like they could be pretty useful, huh?
FlxBasic
  immovable : Boolean
Whether an object will move/alter position after a collision.
FlxObject
  last : FlxPoint
FlxObject
  mass : Number
FlxObject
  maxAngular : Number
Use in conjunction with angularAcceleration for fluid spin speed control.
FlxObject
  maxVelocity : FlxPoint
If you are using acceleration, you can use maxVelocity with it to cap the speed automatically (very useful!).
FlxObject
  moves : Boolean
Set this to false if you want to skip the automatic motion/movement stuff (see updateMotion()).
FlxObject
  scrollFactor : FlxPoint
A point that can store numbers from 0 to 1 (for X and Y independently) that governs how much this object is affected by the camera subsystem.
FlxObject
  solid : Boolean
FlxObject
  touching : uint
Bit field of flags (use with UP, DOWN, LEFT, RIGHT, etc) indicating surface contacts and collision qualities.
FlxObject
  velocity : FlxPoint
The basic speed of this object.
FlxObject
 Inheritedvisible : Boolean
Controls whether draw() is automatically called by FlxState/FlxGroup.
FlxBasic
 Inherited_VISIBLECOUNT : uint
[static]
FlxBasic
  wasTouching : uint
FlxObject
  width : Number
FlxObject
  x : Number
FlxObject
  y : Number
FlxObject
Protected Properties
 PropertyDefined By
  _flicker : Boolean
Internal helper used for retro-style flickering.
FlxObject
  _flickerTimer : Number
Internal helper used for retro-style flickering.
FlxObject
  _point : FlxPoint
This is just a pre-allocated x-y point container to be used however you like
FlxObject
  _rect : FlxRect
This is just a pre-allocated rectangle container to be used however you like
FlxObject
Public Methods
 MethodDefined By
  
FlxObject(X:Number = 0, Y:Number = 0, Width:Number = 0, Height:Number = 0)
Instantiates a FlxObject.
FlxObject
  
destroy():void
[override] Override this function to null out variables or manually call destroy() on class members if necessary.
FlxObject
 Inherited
draw():void
Override this function to control how the object is drawn.
FlxBasic
  
flicker(Duration:Number = 1):void
Tells this object to flicker, retro-style.
FlxObject
  
FlxObject
  
getScreenXY(Point:FlxPoint = null, Camera:FlxCamera = null):FlxPoint
Call this function to figure out the on-screen position of the object.
FlxObject
  
isTouching(Direction:uint):Boolean
FlxObject
  
justTouched(Direction:uint):Boolean
FlxObject
 Inherited
kill():void
FlxBasic
  
onScreen(Camera:FlxCamera = null):Boolean
[override] Check and see if this object is currently on screen.
FlxObject
  
overlaps(Object:FlxObject):Boolean
Checks to see if some FlxObject overlaps this FlxObject object in world space.
FlxObject
  
overlapsPoint(X:Number, Y:Number, Camera:FlxCamera = null, PerPixel:Boolean = false):Boolean
Checks to see if a point in 2D world space overlaps this FlxObject object.
FlxObject
  
postUpdate():void
[override]
FlxObject
  
preUpdate():void
[override]
FlxObject
  
reset(X:Number, Y:Number):void
Handy function for reviving game objects.
FlxObject
 Inherited
revive():void
FlxBasic
  
separate(Object1:FlxObject, Object2:FlxObject):Boolean
[static]
FlxObject
  
separateX(Object1:FlxObject, Object2:FlxObject):Boolean
[static]
FlxObject
  
separateY(Object1:FlxObject, Object2:FlxObject):Boolean
[static]
FlxObject
 Inherited
toString():String
Convert object to readable string name.
FlxBasic
  
update():void
[override] Called by the main game loop, handles motion/physics and game logic
FlxObject
Protected Methods
 MethodDefined By
  
Internal function for updating the position and speed of this object.
FlxObject
Public Constants
 ConstantDefined By
  ANY : uint
[static]
FlxObject
  CEILING : uint = 0x0100
[static]
FlxObject
  DOWN : uint = 0x1000
[static]
FlxObject
  FLOOR : uint = 0x1000
[static]
FlxObject
  LEFT : uint = 0x0001
[static]
FlxObject
  NONE : uint = 0
[static]
FlxObject
  OVERLAP_BIAS : Number = 4
[static]
FlxObject
  RIGHT : uint = 0x0010
[static]
FlxObject
  UP : uint = 0x0100
[static]
FlxObject
  WALL : uint
[static]
FlxObject
Protected Constants
 ConstantDefined By
  _pZero : FlxPoint
[static] A handy "empty point" object
FlxObject
Property Detail
_flickerproperty
protected var _flicker:Boolean

Internal helper used for retro-style flickering.

_flickerTimerproperty 
protected var _flickerTimer:Number

Internal helper used for retro-style flickering.

_pointproperty 
protected var _point:FlxPoint

This is just a pre-allocated x-y point container to be used however you like

_rectproperty 
protected var _rect:FlxRect

This is just a pre-allocated rectangle container to be used however you like

accelerationproperty 
public var acceleration:FlxPoint

How fast the speed of this object is changing. Useful for smooth movement and gravity.

allowCollisionsproperty 
public var allowCollisions:uint

Bit field of flags (use with UP, DOWN, LEFT, RIGHT, etc) indicating collision directions. Use bitwise operators to check the values stored here. Useful for things like one-way platforms (e.g. allowCollisions = UP;) The accessor "solid" just flips this variable between NONE and ANY.

angleproperty 
public var angle:Number

Set the angle of a sprite to rotate it. WARNING: rotating sprites decreases rendering performance for this sprite by a factor of 10x!

angularAccelerationproperty 
public var angularAcceleration:Number

How fast the spin speed should change.

angularDragproperty 
public var angularDrag:Number

Like drag but for spinning.

angularVelocityproperty 
public var angularVelocity:Number

This is how fast you want this sprite to spin.

dragproperty 
public var drag:FlxPoint

This isn't drag exactly, more like deceleration that is only applied when acceleration is not affecting the sprite.

elasticityproperty 
public var elasticity:Number

flickeringproperty 
flickering:Boolean  [read-only]

Check to see if the object is still flickering.


Implementation
    public function get flickering():Boolean
healthproperty 
public var health:Number

Handy for storing health percentage or armor points or whatever.

heightproperty 
public var height:Number

immovableproperty 
public var immovable:Boolean

Whether an object will move/alter position after a collision.

lastproperty 
public var last:FlxPoint

massproperty 
public var mass:Number

maxAngularproperty 
public var maxAngular:Number

Use in conjunction with angularAcceleration for fluid spin speed control.

maxVelocityproperty 
public var maxVelocity:FlxPoint

If you are using acceleration, you can use maxVelocity with it to cap the speed automatically (very useful!).

movesproperty 
public var moves:Boolean

Set this to false if you want to skip the automatic motion/movement stuff (see updateMotion()). FlxObject and FlxSprite default to true. FlxText, FlxTileblock, FlxTilemap and FlxSound default to false.

scrollFactorproperty 
public var scrollFactor:FlxPoint

A point that can store numbers from 0 to 1 (for X and Y independently) that governs how much this object is affected by the camera subsystem. 0 means it never moves, like a HUD element or far background graphic. 1 means it scrolls along a the same speed as the foreground layer. scrollFactor is initialized as (1,1) by default.

solidproperty 
solid:Boolean


Implementation
    public function get solid():Boolean
    public function set solid(value:Boolean):void
touchingproperty 
public var touching:uint

Bit field of flags (use with UP, DOWN, LEFT, RIGHT, etc) indicating surface contacts and collision qualities. Use bitwise operators to check the values stored here, or use touching(), justStartedTouching(), etc. You can even use them broadly as boolean values if you're feeling saucy!

velocityproperty 
public var velocity:FlxPoint

The basic speed of this object.

wasTouchingproperty 
public var wasTouching:uint

widthproperty 
public var width:Number

xproperty 
public var x:Number

yproperty 
public var y:Number

Constructor Detail
FlxObject()Constructor
public function FlxObject(X:Number = 0, Y:Number = 0, Width:Number = 0, Height:Number = 0)

Instantiates a FlxObject.

Parameters
X:Number (default = 0) — The X-coordinate of the point in space.
 
Y:Number (default = 0) — The Y-coordinate of the point in space.
 
Width:Number (default = 0) — Desired width of the rectangle.
 
Height:Number (default = 0) — Desired height of the rectangle.
Method Detail
destroy()method
override public function destroy():void

Override this function to null out variables or manually call destroy() on class members if necessary. Don't forget to call super.destroy()!

flicker()method 
public function flicker(Duration:Number = 1):void

Tells this object to flicker, retro-style. Pass a negative value to flicker forever.

Parameters

Duration:Number (default = 1) — How many seconds to flicker for.

getMidpoint()method 
public function getMidpoint(Point:FlxPoint = null):FlxPoint

Parameters

Point:FlxPoint (default = null)

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

Call this function to figure out the on-screen position of the object.

Parameters

Point:FlxPoint (default = null) — Specify which game camera you want. If null getScreenXY() will just grab the first global camera.
 
Camera:FlxCamera (default = null) — Takes a FlxPoint object and assigns the post-scrolled X and Y values of this object to it.

Returns
FlxPoint — The Point you passed in, or a new Point if you didn't pass one, containing the screen X and Y position of this object.
isTouching()method 
public function isTouching(Direction:uint):Boolean

Parameters

Direction:uint

Returns
Boolean
justTouched()method 
public function justTouched(Direction:uint):Boolean

Parameters

Direction:uint

Returns
Boolean
onScreen()method 
override public function onScreen(Camera:FlxCamera = null):Boolean

Check and see if this object is currently on screen.

Parameters

Camera:FlxCamera (default = null) — Specify which game camera you want. If null getScreenXY() will just grab the first global camera.

Returns
Boolean — Whether the object is on screen or not.
overlaps()method 
public function overlaps(Object:FlxObject):Boolean

Checks to see if some FlxObject overlaps this FlxObject object in world space.

Parameters

Object:FlxObject — The object being tested.

Returns
Boolean — Whether or not the two objects overlap.
overlapsPoint()method 
public function overlapsPoint(X:Number, Y:Number, Camera:FlxCamera = null, PerPixel:Boolean = false):Boolean

Checks to see if a point in 2D world space overlaps this FlxObject object.

Parameters

X:Number — The X coordinate of the point.
 
Y:Number — The Y coordinate of the point.
 
Camera:FlxCamera (default = null) — Specify which game camera you want. If null getScreenXY() will just grab the first global camera.
 
PerPixel:Boolean (default = false) — Whether or not to use per pixel collision checking (only available in FlxSprite subclass).

Returns
Boolean — Whether or not the point overlaps this object.
postUpdate()method 
override public function postUpdate():void

preUpdate()method 
override public function preUpdate():void

reset()method 
public function reset(X:Number, Y:Number):void

Handy function for reviving game objects. Resets their existence flags and position, including LAST position.

Parameters

X:Number — The new X position of this object.
 
Y:Number — The new Y position of this object.

separate()method 
public static function separate(Object1:FlxObject, Object2:FlxObject):Boolean

Parameters

Object1:FlxObject
 
Object2:FlxObject

Returns
Boolean
separateX()method 
public static function separateX(Object1:FlxObject, Object2:FlxObject):Boolean

Parameters

Object1:FlxObject
 
Object2:FlxObject

Returns
Boolean
separateY()method 
public static function separateY(Object1:FlxObject, Object2:FlxObject):Boolean

Parameters

Object1:FlxObject
 
Object2:FlxObject

Returns
Boolean
update()method 
override public function update():void

Called by the main game loop, handles motion/physics and game logic

updateMotion()method 
protected function updateMotion():void

Internal function for updating the position and speed of this object. Useful for cases when you need to update this but are buried down in too many supers.

Constant Detail
_pZeroConstant
protected static const _pZero:FlxPoint

A handy "empty point" object

ANYConstant 
public static const ANY:uint

CEILINGConstant 
public static const CEILING:uint = 0x0100

DOWNConstant 
public static const DOWN:uint = 0x1000

FLOORConstant 
public static const FLOOR:uint = 0x1000

LEFTConstant 
public static const LEFT:uint = 0x0001

NONEConstant 
public static const NONE:uint = 0

OVERLAP_BIASConstant 
public static const OVERLAP_BIAS:Number = 4

RIGHTConstant 
public static const RIGHT:uint = 0x0010

UPConstant 
public static const UP:uint = 0x0100

WALLConstant 
public static const WALL:uint