Package | org.flixel |
Class | public class FlxGroup |
Inheritance | FlxGroup ![]() ![]() ![]() |
Subclasses | FlxButton, FlxEmitter, FlxPause |
FlxObject
s.
NOTE: Although FlxGroup
extends FlxObject
, it will not automatically
add itself to the global collisions quad tree, it will only add its members.
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 | |
members : Array
Array of all the
FlxObject s that exist in this layer. | FlxGroup | ||
![]() | 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 | ||
---|---|---|---|
_first : Boolean | FlxGroup | ||
![]() | _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 | |
_last : FlxPoint
Helpers for moving/updating group members.
| FlxGroup | ||
![]() | _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 | |
_sortIndex : String
Helpers for sorting members.
| FlxGroup | ||
_sortOrder : int | FlxGroup |
Method | Defined by | ||
---|---|---|---|
FlxGroup()
Constructor
| FlxGroup | ||
Adds a new
FlxObject subclass (FlxSprite, FlxBlock, etc) to the list of children
| FlxGroup | ||
![]() |
If you don't want to call
FlxU.collide() you can use this instead. | FlxObject | |
countDead():int
Call this function to find out how many members of the group are dead.
| FlxGroup | ||
countLiving():int
Call this function to find out how many members of the group are not dead.
| FlxGroup | ||
countOnScreen():int
Returns a count of how many objects in this group are on-screen right now.
| FlxGroup | ||
destroy():void
Override this function to handle any deleting or "shutdown" type operations you might need,
such as removing traditional Flash children like Sprite objects.
| FlxGroup | ||
![]() |
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 retrieve the first object with dead == false in the group.
| FlxGroup | ||
Call this function to retrieve the first object with exists == false in the group.
| FlxGroup | ||
Call this function to retrieve the first object with dead == true in the group.
| FlxGroup | ||
Call this function to retrieve the first object with exists == true in the group.
| FlxGroup | ||
getFirstNull():int
Call this function to retrieve the first index set to 'null'.
| FlxGroup | ||
Returns a member at random from the group.
| FlxGroup | ||
![]() |
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
Calls kill on the group and all its members.
| FlxGroup | ||
![]() |
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 | |
Removes an object from the group.
| FlxGroup | ||
render():void
Automatically goes through and calls render on everything you added,
override this loop to control render order manually.
| FlxGroup | ||
Replaces an existing
FlxObject with a new one. | FlxGroup | ||
reset(X:Number, Y:Number):void
If the group's position is reset, we want to reset all its members too.
| FlxGroup | ||
resetFirstAvail(X:Number = 0, Y:Number = 0):Boolean
Finds the first object with exists == false and calls reset on it.
| FlxGroup | ||
sort(Index:String = "y", Order:int):void
Call this function to sort the group according to a particular value and order.
| FlxGroup | ||
![]() |
toString():String
Convert object to readable string name.
| FlxPoint | |
update():void
Automatically goes through and calls update on everything you added,
override this function to handle custom input and perform collisions.
| FlxGroup |
Method | Defined by | ||
---|---|---|---|
destroyMembers():void
Internal function that actually loops through and destroys each member.
| FlxGroup | ||
killMembers():void
Internal function that calls kill on all members.
| FlxGroup | ||
renderMembers():void
Internal function that actually loops through and renders all the group members.
| FlxGroup | ||
saveOldPosition():void
Internal function, helps with the moving/updating of group members.
| FlxGroup | ||
Helper function for the sort process.
| FlxGroup | ||
![]() |
updateFlickering():void
Just updates the retro-style flickering.
| FlxObject | |
updateMembers():void
Internal function that actually goes through and updates all the group members.
| FlxGroup | ||
![]() |
updateMotion():void
Internal function for updating the position and speed of this object.
| FlxObject |
Constant | Defined by | ||
---|---|---|---|
ASCENDING : int = -1 [static]
| FlxGroup | ||
DESCENDING : int = 1 [static]
| FlxGroup |
_first | property |
protected var _first:Boolean
_last | property |
protected var _last:FlxPoint
Helpers for moving/updating group members.
members | property |
public var members:Array
Array of all the FlxObject
s that exist in this layer.
_sortIndex | property |
protected var _sortIndex:String
Helpers for sorting members.
_sortOrder | property |
protected var _sortOrder:int
FlxGroup | () | constructor |
public function FlxGroup()
Constructor
add | () | method |
public function add(Object:FlxObject, ShareScroll:Boolean = false):FlxObject
Adds a new FlxObject
subclass (FlxSprite, FlxBlock, etc) to the list of children
Object:FlxObject — The object you want to add
|
|
ShareScroll:Boolean (default = false ) — Whether or not this FlxObject should sync up with this layer's scrollFactor
|
FlxObject —
The same FlxObject object that was passed in.
|
countDead | () | method |
public function countDead():int
Call this function to find out how many members of the group are dead.
Returnsint — The number of FlxObject s flagged as dead. Returns -1 if group is empty.
|
countLiving | () | method |
public function countLiving():int
Call this function to find out how many members of the group are not dead.
Returnsint — The number of FlxObject s flagged as not dead. Returns -1 if group is empty.
|
countOnScreen | () | method |
public function countOnScreen():int
Returns a count of how many objects in this group are on-screen right now.
Returnsint — The number of FlxObject s that are on screen. Returns -1 if group is empty.
|
destroy | () | method |
public override function destroy():void
Override this function to handle any deleting or "shutdown" type operations you might need, such as removing traditional Flash children like Sprite objects.
destroyMembers | () | method |
protected function destroyMembers():void
Internal function that actually loops through and destroys each member.
getFirstAlive | () | method |
public function getFirstAlive():FlxObject
Call this function to retrieve the first object with dead == false in the group. This is handy for checking if everything's wiped out, or choosing a squad leader, etc.
ReturnsFlxObject —
A FlxObject currently flagged as not dead.
|
getFirstAvail | () | method |
public function getFirstAvail():FlxObject
Call this function to retrieve the first object with exists == false in the group. This is handy for recycling in general, e.g. respawning enemies.
ReturnsFlxObject —
A FlxObject currently flagged as not existing.
|
getFirstDead | () | method |
public function getFirstDead():FlxObject
Call this function to retrieve the first object with dead == true in the group. This is handy for checking if everything's wiped out, or choosing a squad leader, etc.
ReturnsFlxObject —
A FlxObject currently flagged as dead.
|
getFirstExtant | () | method |
public function getFirstExtant():FlxObject
Call this function to retrieve the first object with exists == true in the group. This is handy for checking if everything's wiped out, or choosing a squad leader, etc.
ReturnsFlxObject —
A FlxObject currently flagged as existing.
|
getFirstNull | () | method |
public function getFirstNull():int
Call this function to retrieve the first index set to 'null'. Returns -1 if no index stores a null object.
Returnsint — An int indicating the first null slot in the group.
|
getRandom | () | method |
public function getRandom():FlxObject
Returns a member at random from the group.
ReturnsFlxObject —
A FlxObject from the members list.
|
kill | () | method |
public override function kill():void
Calls kill on the group and all its members.
killMembers | () | method |
protected function killMembers():void
Internal function that calls kill on all members.
remove | () | method |
public function remove(Object:FlxObject, Splice:Boolean = false):FlxObject
Removes an object from the group.
ParametersObject:FlxObject — The FlxObject you want to remove.
|
|
Splice:Boolean (default = false ) — Whether the object should be cut from the array entirely or not.
|
FlxObject —
The removed object.
|
render | () | method |
public override function render():void
Automatically goes through and calls render on everything you added, override this loop to control render order manually.
renderMembers | () | method |
protected function renderMembers():void
Internal function that actually loops through and renders all the group members.
replace | () | method |
public function replace(OldObject:FlxObject, NewObject:FlxObject):FlxObject
Replaces an existing FlxObject
with a new one.
OldObject:FlxObject — The object you want to replace.
|
|
NewObject:FlxObject — The new object you want to use instead.
|
FlxObject —
The new object.
|
reset | () | method |
public override function reset(X:Number, Y:Number):void
If the group's position is reset, we want to reset all its members too.
ParametersX:Number — The new X position of this object.
|
|
Y:Number — The new Y position of this object.
|
resetFirstAvail | () | method |
public function resetFirstAvail(X:Number = 0, Y:Number = 0):Boolean
Finds the first object with exists == false and calls reset on it.
ParametersX:Number (default = 0 ) — The new X position of this object.
|
|
Y:Number (default = 0 ) — The new Y position of this object.
|
Boolean — Whether a suitable FlxObject was found and reset.
|
saveOldPosition | () | method |
protected function saveOldPosition():void
Internal function, helps with the moving/updating of group members.
sort | () | method |
public function sort(Index:String = "y", Order:int):void
Call this function to sort the group according to a particular value and order.
For example, to sort game objects for Zelda-style overlaps you might call
myGroup.sort("y",ASCENDING)
at the bottom of your
FlxState.update()
override. To sort all existing objects after
a big explosion or bomb attack, you might call myGroup.sort("exists",DESCENDING)
.
Index:String (default = "y ") — The String name of the member variable you want to sort on. Default value is "y".
|
|
Order:int — A FlxGroup constant that defines the sort order. Possible values are ASCENDING and DESCENDING . Default value is ASCENDING .
|
sortHandler | () | method |
protected function sortHandler(Obj1:FlxObject, Obj2:FlxObject):int
Helper function for the sort process.
ParametersObj1:FlxObject — Obj1 The first object being sorted.
|
|
Obj2:FlxObject — The second object being sorted.
|
int — An integer value: -1 (Obj1 before Obj2), 0 (same), or 1 (Obj1 after Obj2).
|
update | () | method |
public override function update():void
Automatically goes through and calls update on everything you added, override this function to handle custom input and perform collisions.
updateMembers | () | method |
protected function updateMembers():void
Internal function that actually goes through and updates all the group members.
Depends on saveOldPosition()
to set up the correct values in _last
in order to work properly.
ASCENDING | constant |
public static const ASCENDING:int = -1
DESCENDING | constant |
public static const DESCENDING:int = 1