| Package | org.flixel |
| Class | public class FlxObject |
| Inheritance | FlxObject FlxRect FlxPoint |
| Subclasses | FlxGroup, FlxPanel, FlxSound, FlxSprite, FlxTilemap |
FlxSprite, FlxText, etc).
It includes some basic attributes about game objects, including retro-style flickering,
basic state information, sizes, scrolling, and basic physics & motion.
| Property | Defined by | ||
|---|---|---|---|
| acceleration : FlxPoint
How fast the speed of this object is changing.
| FlxObject | ||
| active : Boolean
If an object is not alive, the game loop will not automatically call
update() on it. | 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 | ||
![]() | bottom : Number
The Y coordinate of the bottom of the rectangle.
| FlxRect | |
| colHullX : FlxRect
These store a couple of useful numbers for speeding up collision resolution.
| FlxObject | ||
| colHullY : FlxRect
These store a couple of useful numbers for speeding up collision resolution.
| FlxObject | ||
| collideBottom : Boolean
Flag for direction collision resolution.
| FlxObject | ||
| collideLeft : Boolean
Flag for direction collision resolution.
| FlxObject | ||
| collideRight : Boolean
Flag for direction collision resolution.
| FlxObject | ||
| collideTop : Boolean
Flag for direction collision resolution.
| FlxObject | ||
| colOffsets : Array
An array of
FlxPoint objects. | FlxObject | ||
| colVector : FlxPoint
These store a couple of useful numbers for speeding up collision resolution.
| FlxObject | ||
| dead : Boolean
Handy for tracking gameplay or animations.
| FlxObject | ||
| drag : FlxPoint
This isn't drag exactly, more like deceleration that is only applied
when acceleration is not affecting the sprite.
| FlxObject | ||
| exists : Boolean
Kind of a global on/off switch for any objects descended from
FlxObject. | FlxObject | ||
| fixed : Boolean
Set
fixed to true if you want the object to stay in place during collisions. | FlxObject | ||
| _group : Boolean
Dedicated internal flag for whether or not this class is a FlxGroup.
| FlxObject | ||
| health : Number
Handy for storing health percentage or armor points or whatever.
| FlxObject | ||
![]() | height : Number | FlxRect | |
![]() | left : Number
The X coordinate of the left side of the rectangle.
| FlxRect | |
| maxAngular : Number
Use in conjunction with
angularAcceleration for fluid spin speed control. | FlxObject | ||
| maxThrust : Number
Used to cap
thrust, helpful and easy!
| 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 | ||
| onFloor : Boolean
Flag that indicates whether or not you just hit the floor.
| FlxObject | ||
| origin : FlxPoint
WARNING: The origin of the sprite will default to its center.
| FlxObject | ||
![]() | right : Number
The X coordinate of the right side of the rectangle.
| FlxRect | |
| 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
Set
solid to true if you want to collide this object. | FlxObject | ||
| thrust : Number
If you want to do Asteroids style stuff, check out thrust,
instead of directly accessing the object's velocity or acceleration.
| FlxObject | ||
![]() | top : Number
The Y coordinate of the top of the rectangle.
| FlxRect | |
| velocity : FlxPoint
The basic speed of this object.
| FlxObject | ||
| visible : Boolean
If an object is not visible, the game loop will not automatically call
render() on it. | FlxObject | ||
![]() | width : Number | FlxRect | |
![]() | x : Number | FlxPoint | |
![]() | y : Number | FlxPoint | |
| Property | Defined by | ||
|---|---|---|---|
| _fixed : Boolean
Internal tracker for whether an object will move/alter position after a collision (see
fixed). | FlxObject | ||
| _flashPoint : Point
This is a pre-allocated Flash Point object, which is useful for certain Flash graphics API calls
| FlxObject | ||
| _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 | ||
| _solid : Boolean
Internal tracker for whether or not the object collides (see
solid). | FlxObject | ||
| Method | Defined by | ||
|---|---|---|---|
|
FlxObject(X:Number = 0, Y:Number = 0, Width:Number = 0, Height:Number = 0)
Creates a new
FlxObject. | FlxObject | ||
|
If you don't want to call
FlxU.collide() you can use this instead. | FlxObject | ||
|
destroy():void
Called by
FlxGroup, commonly when game states are changed. | FlxObject | ||
|
flicker(Duration:Number = 1):void
Tells this object to flicker, retro-style.
| FlxObject | ||
|
flickering():Boolean
Check to see if the object is still flickering.
| FlxObject | ||
|
getBoundingColor():uint
Returns the appropriate color for the bounding box depending on object state.
| FlxObject | ||
|
Call this function to figure out the on-screen position of the object.
| FlxObject | ||
|
Called when this object's bottom edge collides with the top of another
FlxObject. | FlxObject | ||
|
Called when this object's left side collides with another
FlxObject's right. | FlxObject | ||
|
Called when this object's right side collides with another
FlxObject's left. | FlxObject | ||
|
Since most games have identical behavior for running into walls,
you can just override this function instead of overriding both hitLeft and hitRight.
| FlxObject | ||
|
Called when this object's top collides with the bottom of another
FlxObject. | FlxObject | ||
|
hurt(Damage:Number):void
Call this function to "damage" (or give health bonus) to this sprite.
| FlxObject | ||
|
kill():void
Call this function to "kill" a sprite so that it no longer 'exists'.
| FlxObject | ||
|
onScreen():Boolean
Check and see if this object is currently on screen.
| FlxObject | ||
|
Checks to see if some
FlxObject object overlaps this FlxObject object. | FlxObject | ||
|
overlapsPoint(X:Number, Y:Number, PerPixel:Boolean = false):Boolean
Checks to see if a point in 2D space overlaps this
FlxObject object. | FlxObject | ||
|
preCollide(Object:FlxObject):void
FlxU.collide() (and thus FlxObject.collide()) call
this function each time two objects are compared to see if they collide. | FlxObject | ||
|
refreshHulls():void
Called by
FlxObject.updateMotion() and some constructors to
rebuild the basic collision data for this object. | FlxObject | ||
|
render():void
Override this function to draw graphics (see
FlxSprite). | FlxObject | ||
|
reset(X:Number, Y:Number):void
Handy function for reviving game objects.
| FlxObject | ||
![]() |
toString():String
Convert object to readable string name.
| FlxPoint | |
|
update():void
Called by the main game loop, handles motion/physics and game logic
| FlxObject | ||
| Method | Defined by | ||
|---|---|---|---|
|
updateFlickering():void
Just updates the retro-style flickering.
| FlxObject | ||
|
updateMotion():void
Internal function for updating the position and speed of this object.
| FlxObject | ||
| Constant | Defined by | ||
|---|---|---|---|
| _pZero : FlxPoint
[static]
A handy "empty point" object
| FlxObject | ||
| acceleration | property |
public var acceleration:FlxPointHow fast the speed of this object is changing. Useful for smooth movement and gravity.
| active | property |
public var active:Boolean
If an object is not alive, the game loop will not automatically call update() on it.
| angle | property |
public var angle:NumberSet the angle of a sprite to rotate it. WARNING: rotating sprites decreases rendering performance for this sprite by a factor of 10x!
| angularAcceleration | property |
public var angularAcceleration:NumberHow fast the spin speed should change.
| angularDrag | property |
public var angularDrag:Number
Like drag but for spinning.
| angularVelocity | property |
public var angularVelocity:NumberThis is how fast you want this sprite to spin.
| colHullX | property |
public var colHullX:FlxRectThese store a couple of useful numbers for speeding up collision resolution.
| colHullY | property |
public var colHullY:FlxRectThese store a couple of useful numbers for speeding up collision resolution.
| collideBottom | property |
public var collideBottom:BooleanFlag for direction collision resolution.
| collideLeft | property |
public var collideLeft:BooleanFlag for direction collision resolution.
| collideRight | property |
public var collideRight:BooleanFlag for direction collision resolution.
| collideTop | property |
public var collideTop:BooleanFlag for direction collision resolution.
| colOffsets | property |
public var colOffsets:Array
An array of FlxPoint objects. By default contains a single offset (0,0).
| colVector | property |
public var colVector:FlxPointThese store a couple of useful numbers for speeding up collision resolution.
| dead | property |
public var dead:BooleanHandy for tracking gameplay or animations.
| drag | property |
public var drag:FlxPointThis isn't drag exactly, more like deceleration that is only applied when acceleration is not affecting the sprite.
| exists | property |
public var exists:Boolean
Kind of a global on/off switch for any objects descended from FlxObject.
| _fixed | property |
protected var _fixed:Boolean
Internal tracker for whether an object will move/alter position after a collision (see fixed).
| fixed | property |
fixed:Boolean [read-write]
Set fixed to true if you want the object to stay in place during collisions.
Useful for levels and other environmental objects.
public function get fixed():Boolean
public function set fixed(value:Boolean):void
| _flashPoint | property |
protected var _flashPoint:PointThis is a pre-allocated Flash Point object, which is useful for certain Flash graphics API calls
| _flicker | property |
protected var _flicker:BooleanInternal helper used for retro-style flickering.
| _flickerTimer | property |
protected var _flickerTimer:NumberInternal helper used for retro-style flickering.
| _group | property |
public var _group:BooleanDedicated internal flag for whether or not this class is a FlxGroup.
| health | property |
public var health:NumberHandy for storing health percentage or armor points or whatever.
| maxAngular | property |
public var maxAngular:Number
Use in conjunction with angularAcceleration for fluid spin speed control.
| maxThrust | property |
public var maxThrust:Number
Used to cap thrust, helpful and easy!
| maxVelocity | property |
public var maxVelocity:FlxPoint
If you are using acceleration, you can use maxVelocity with it
to cap the speed automatically (very useful!).
| moves | property |
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.
| onFloor | property |
public var onFloor:Boolean
Flag that indicates whether or not you just hit the floor.
Primarily useful for platformers, this flag is reset during the updateMotion().
| origin | property |
public var origin:FlxPointWARNING: The origin of the sprite will default to its center. If you change this, the visuals and the collisions will likely be pretty out-of-sync if you do any rotation.
| _point | property |
protected var _point:FlxPointThis is just a pre-allocated x-y point container to be used however you like
| _rect | property |
protected var _rect:FlxRectThis is just a pre-allocated rectangle container to be used however you like
| scrollFactor | property |
public var scrollFactor:FlxPointA 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.
| _solid | property |
protected var _solid:Boolean
Internal tracker for whether or not the object collides (see solid).
| solid | property |
solid:Boolean [read-write]
Set solid to true if you want to collide this object.
public function get solid():Boolean
public function set solid(value:Boolean):void
| thrust | property |
public var thrust:NumberIf you want to do Asteroids style stuff, check out thrust, instead of directly accessing the object's velocity or acceleration.
| velocity | property |
public var velocity:FlxPointThe basic speed of this object.
| visible | property |
public var visible:Boolean
If an object is not visible, the game loop will not automatically call render() on it.
| FlxObject | () | constructor |
public function FlxObject(X:Number = 0, Y:Number = 0, Width:Number = 0, Height:Number = 0)
Creates a new FlxObject.
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.
|
| collide | () | method |
public function collide(Object:FlxObject = null):Boolean
If you don't want to call FlxU.collide() you can use this instead.
Just calls FlxU.collide(this,Object);. Will collide against itself
if Object==null.
Object:FlxObject (default = null) — The |
Boolean |
| destroy | () | method |
public function destroy():void
Called by FlxGroup, commonly when game states are changed.
| flicker | () | method |
public function flicker(Duration:Number = 1):voidTells this object to flicker, retro-style.
ParametersDuration:Number (default = 1) — How many seconds to flicker for.
|
| flickering | () | method |
public function flickering():BooleanCheck to see if the object is still flickering.
ReturnsBoolean — Whether the object is flickering or not.
|
| getBoundingColor | () | method |
public function getBoundingColor():uintReturns the appropriate color for the bounding box depending on object state.
Returnsuint |
| getScreenXY | () | method |
public function getScreenXY(Point:FlxPoint = null):FlxPointCall this function to figure out the on-screen position of the object.
ParametersPoint:FlxPoint (default = null) — Takes a Point object and assigns the post-scrolled X and Y values of this object to it.
|
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.
|
| hitBottom | () | method |
public function hitBottom(Contact:FlxObject, Velocity:Number):void
Called when this object's bottom edge collides with the top of another FlxObject.
Contact:FlxObject — The FlxObject you just ran into.
|
|
Velocity:Number — The suggested new velocity for this object.
|
| hitLeft | () | method |
public function hitLeft(Contact:FlxObject, Velocity:Number):void
Called when this object's left side collides with another FlxObject's right.
NOTE: by default this function just calls hitSide().
Contact:FlxObject — The FlxObject you just ran into.
|
|
Velocity:Number — The suggested new velocity for this object.
|
| hitRight | () | method |
public function hitRight(Contact:FlxObject, Velocity:Number):void
Called when this object's right side collides with another FlxObject's left.
NOTE: by default this function just calls hitSide().
Contact:FlxObject — The FlxObject you just ran into.
|
|
Velocity:Number — The suggested new velocity for this object.
|
| hitSide | () | method |
public function hitSide(Contact:FlxObject, Velocity:Number):voidSince most games have identical behavior for running into walls, you can just override this function instead of overriding both hitLeft and hitRight.
ParametersContact:FlxObject — The FlxObject you just ran into.
|
|
Velocity:Number — The suggested new velocity for this object.
|
| hitTop | () | method |
public function hitTop(Contact:FlxObject, Velocity:Number):void
Called when this object's top collides with the bottom of another FlxObject.
Contact:FlxObject — The FlxObject you just ran into.
|
|
Velocity:Number — The suggested new velocity for this object.
|
| hurt | () | method |
public function hurt(Damage:Number):voidCall this function to "damage" (or give health bonus) to this sprite.
ParametersDamage:Number — How much health to take away (use a negative number to give a health bonus).
|
| kill | () | method |
public function kill():voidCall this function to "kill" a sprite so that it no longer 'exists'.
| onScreen | () | method |
public function onScreen():BooleanCheck and see if this object is currently on screen.
ReturnsBoolean — Whether the object is on screen or not.
|
| overlaps | () | method |
public function overlaps(Object:FlxObject):Boolean
Checks to see if some FlxObject object overlaps this FlxObject object.
Object:FlxObject — The object being tested.
|
Boolean — Whether or not the two objects overlap.
|
| overlapsPoint | () | method |
public function overlapsPoint(X:Number, Y:Number, PerPixel:Boolean = false):Boolean
Checks to see if a point in 2D space overlaps this FlxObject object.
X:Number — The X coordinate of the point.
|
|
Y:Number — The Y coordinate of the point.
|
|
PerPixel:Boolean (default = false) — Whether or not to use per pixel collision checking (only available in FlxSprite subclass).
|
Boolean — Whether or not the point overlaps this object.
|
| preCollide | () | method |
public function preCollide(Object:FlxObject):void
FlxU.collide() (and thus FlxObject.collide()) call
this function each time two objects are compared to see if they collide.
It doesn't necessarily mean these objects WILL collide, however.
Object:FlxObject — The FlxObject you're about to run into.
|
| refreshHulls | () | method |
public function refreshHulls():void
Called by FlxObject.updateMotion() and some constructors to
rebuild the basic collision data for this object.
| render | () | method |
public function render():void
Override this function to draw graphics (see FlxSprite).
| reset | () | method |
public function reset(X:Number, Y:Number):voidHandy function for reviving game objects. Resets their existence flags and position, including LAST position.
ParametersX:Number — The new X position of this object.
|
|
Y:Number — The new Y position of this object.
|
| update | () | method |
public function update():voidCalled by the main game loop, handles motion/physics and game logic
| updateFlickering | () | method |
protected function updateFlickering():voidJust updates the retro-style flickering. Considered update logic rather than rendering because it toggles visibility.
| updateMotion | () | method |
protected function updateMotion():voidInternal 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.
| _pZero | constant |
protected static const _pZero:FlxPointA handy "empty point" object