Package | org.flixel |
Class | public class FlxObject |
Inheritance | FlxObject ![]() ![]() |
Subclasses | FlxSprite, FlxTile, FlxTilemap |
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.
Property | Defined By | ||
---|---|---|---|
acceleration : FlxPoint
How fast the speed of this object is changing. | FlxObject | ||
![]() | active : Boolean
Controls whether update() is automatically called by FlxState/FlxGroup. | FlxBasic | |
![]() | _ACTIVECOUNT : uint [static] | FlxBasic | |
![]() | alive : 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 | ||
![]() | exists : 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 | ||
![]() | ID : 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 | ||
![]() | visible : Boolean
Controls whether draw() is automatically called by FlxState/FlxGroup. | FlxBasic | |
![]() | _VISIBLECOUNT : uint [static] | FlxBasic | |
wasTouching : uint | FlxObject | ||
width : Number | FlxObject | ||
x : Number | FlxObject | ||
y : Number | FlxObject |
Property | Defined 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 |
Method | Defined 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 | ||
![]() | 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 | |||
Call this function to figure out the on-screen position of the object. | FlxObject | ||
isTouching(Direction:uint):Boolean | FlxObject | ||
justTouched(Direction:uint):Boolean | FlxObject | ||
![]() | kill():void | FlxBasic | |
[override]
Check and see if this object is currently on screen. | FlxObject | ||
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 | ||
![]() | revive():void | FlxBasic | |
[static] | FlxObject | ||
[static] | FlxObject | ||
[static] | FlxObject | ||
![]() | 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 |
Method | Defined By | ||
---|---|---|---|
updateMotion():void
Internal function for updating the position and speed of this object. | FlxObject |
Constant | Defined 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 |
Constant | Defined By | ||
---|---|---|---|
_pZero : FlxPoint [static]
A handy "empty point" object
| FlxObject |
_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.
_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.
allowCollisions | property |
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.
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.
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.
elasticity | property |
public var elasticity:Number
flickering | property |
flickering:Boolean
[read-only] Check to see if the object is still flickering.
public function get flickering():Boolean
health | property |
public var health:Number
Handy for storing health percentage or armor points or whatever.
height | property |
public var height:Number
immovable | property |
public var immovable:Boolean
Whether an object will move/alter position after a collision.
last | property |
public var last:FlxPoint
mass | property |
public var mass:Number
maxAngular | property |
public var maxAngular:Number
Use in conjunction with angularAcceleration
for fluid spin speed control.
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.
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 |
solid:Boolean
public function get solid():Boolean
public function set solid(value:Boolean):void
touching | property |
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!
velocity | property |
public var velocity:FlxPoint
The basic speed of this object.
wasTouching | property |
public var wasTouching:uint
width | property |
public var width:Number
x | property |
public var x:Number
y | property |
public var y:Number
FlxObject | () | Constructor |
public function FlxObject(X:Number = 0, Y:Number = 0, Width:Number = 0, Height:Number = 0)
Instantiates a 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.
|
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 )
|
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.
|
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 |
Boolean |
justTouched | () | method |
public function justTouched(Direction:uint):Boolean
Parameters
Direction:uint |
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.
|
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.
|
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).
|
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 |
Boolean |
separateX | () | method |
public static function separateX(Object1:FlxObject, Object2:FlxObject):Boolean
Parameters
Object1:FlxObject | |
Object2:FlxObject |
Boolean |
separateY | () | method |
public static function separateY(Object1:FlxObject, Object2:FlxObject):Boolean
Parameters
Object1:FlxObject | |
Object2:FlxObject |
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.
_pZero | Constant |
protected static const _pZero:FlxPoint
A handy "empty point" object
ANY | Constant |
public static const ANY:uint
CEILING | Constant |
public static const CEILING:uint = 0x0100
DOWN | Constant |
public static const DOWN:uint = 0x1000
FLOOR | Constant |
public static const FLOOR:uint = 0x1000
LEFT | Constant |
public static const LEFT:uint = 0x0001
NONE | Constant |
public static const NONE:uint = 0
OVERLAP_BIAS | Constant |
public static const OVERLAP_BIAS:Number = 4
RIGHT | Constant |
public static const RIGHT:uint = 0x0010
UP | Constant |
public static const UP:uint = 0x0100
WALL | Constant |
public static const WALL:uint