Package | org.flixel |
Class | public class FlxObject |
Inheritance | FlxObject FlxRect FlxPoint Object |
Subclasses | FlxGroup, FlxPanel, FlxSound, FlxSprite, TileLayer |
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 [read-only]
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
If an object is 'fixed' in space, it will not budge when it collides with a not-fixed object. | 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 [read-only]
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 [read-only]
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
If an object is dead, the functions that automate collisions will skip it (see FlxG.overlapArrays() and FlxG.collideArrays()). | 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 [read-only]
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 | ||
---|---|---|---|
_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 |
Method | Defined By | ||
---|---|---|---|
FlxObject(X:Number = 0, Y:Number = 0, Width:Number = 0, Height:Number = 0)
Creates a new FlxObject. | FlxObject | ||
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 | ||
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 | ||
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 |
_flashPoint | property |
protected var _flashPoint:Point
This is a pre-allocated Flash Point object, which is useful for certain Flash graphics API calls
_flicker | property |
protected var _flicker:Boolean
Internal helper used for retro-style flickering.
_flickerTimer | property |
protected var _flickerTimer:Number
Internal helper used for retro-style flickering.
_group | property |
public var _group:Boolean
Dedicated internal flag for whether or not this class is a FlxGroup.
_point | property |
protected var _point:FlxPoint
This is just a pre-allocated x-y point container to be used however you like
_rect | property |
protected var _rect:FlxRect
This is just a pre-allocated rectangle container to be used however you like
acceleration | property |
public var acceleration:FlxPoint
How 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:Number
Set 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:Number
How fast the spin speed should change.
angularDrag | property |
public var angularDrag:Number
Like drag
but for spinning.
angularVelocity | property |
public var angularVelocity:Number
This is how fast you want this sprite to spin.
colHullX | property |
public var colHullX:FlxRect
These store a couple of useful numbers for speeding up collision resolution.
colHullY | property |
public var colHullY:FlxRect
These store a couple of useful numbers for speeding up collision resolution.
collideBottom | property |
public var collideBottom:Boolean
Flag for direction collision resolution.
collideLeft | property |
public var collideLeft:Boolean
Flag for direction collision resolution.
collideRight | property |
public var collideRight:Boolean
Flag for direction collision resolution.
collideTop | property |
public var collideTop:Boolean
Flag 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:FlxPoint
These store a couple of useful numbers for speeding up collision resolution.
dead | property |
public var dead:Boolean
Handy for tracking gameplay or animations.
drag | property |
public var drag:FlxPoint
This 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 |
public var fixed:Boolean
If an object is 'fixed' in space, it will not budge when it collides with a not-fixed object. Fixed objects also shortcut out of updateMotion by default.
health | property |
public var health:Number
Handy 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:FlxPoint
WARNING: 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.
scrollFactor | property |
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.
solid | property |
public var solid:Boolean
If an object is dead, the functions that automate collisions will skip it (see FlxG.overlapArrays()
and FlxG.collideArrays()
).
thrust | property |
public var thrust:Number
If 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:FlxPoint
The 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
Parameters
Object:FlxObject (default = null )
|
Boolean |
destroy | () | method |
public function destroy():void
Called by FlxGroup
, commonly when game states are changed.
flicker | () | method |
public function flicker(Duration:Number = 1):void
Tells this object to flicker, retro-style.
Parameters
Duration:Number (default = 1 ) — How many seconds to flicker for.
|
flickering | () | method |
public function flickering():Boolean
Check to see if the object is still flickering.
ReturnsBoolean — Whether the object is flickering or not.
|
getScreenXY | () | method |
public function getScreenXY(Point:FlxPoint = null):FlxPoint
Call this function to figure out the on-screen position of the object.
Parameters
Point: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
.
Parameters
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.
Parameters
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.
Parameters
Contact: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
.
Parameters
Contact:FlxObject — The FlxObject you just ran into.
| |
Velocity:Number — The suggested new velocity for this object.
|
hurt | () | method |
public function hurt(Damage:Number):void
Call this function to "damage" (or give health bonus) to this sprite.
Parameters
Damage:Number — How much health to take away (use a negative number to give a health bonus).
|
kill | () | method |
public function kill():void
Call this function to "kill" a sprite so that it no longer 'exists'.
onScreen | () | method |
public function onScreen():Boolean
Check 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.
Parameters
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.
Parameters
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.
Parameters
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):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.
|
update | () | method |
public function update():void
Called by the main game loop, handles motion/physics and game logic
updateFlickering | () | method |
protected function updateFlickering():void
Just updates the retro-style flickering. Considered update logic rather than rendering because it toggles visibility.
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.
_pZero | Constant |
protected static const _pZero:FlxPoint
A handy "empty point" object