Packageorg.flixel
Classpublic class FlxGroup
InheritanceFlxGroup Inheritance FlxObject Inheritance FlxRect Inheritance FlxPoint Inheritance Object
Subclasses FlxButton, FlxPause, Layer, Panel

This is an organizational class that can update and render a bunch of FlxObjects. NOTE: Although FlxGroup extends FlxObject, it will not automatically add itself to the global collisions quad tree, it will only add its members.



Public Properties
 PropertyDefined By
 Inheritedacceleration : FlxPoint
How fast the speed of this object is changing.
FlxObject
 Inheritedactive : Boolean
If an object is not alive, the game loop will not automatically call update() on it.
FlxObject
 Inheritedangle : Number
Set the angle of a sprite to rotate it.
FlxObject
 InheritedangularAcceleration : Number
How fast the spin speed should change.
FlxObject
 InheritedangularDrag : Number
Like drag but for spinning.
FlxObject
 InheritedangularVelocity : Number
This is how fast you want this sprite to spin.
FlxObject
 Inheritedbottom : Number
[read-only] The Y coordinate of the bottom of the rectangle.
FlxRect
 InheritedcolHullX : FlxRect
These store a couple of useful numbers for speeding up collision resolution.
FlxObject
 InheritedcolHullY : FlxRect
These store a couple of useful numbers for speeding up collision resolution.
FlxObject
 InheritedcollideBottom : Boolean
Flag for direction collision resolution.
FlxObject
 InheritedcollideLeft : Boolean
Flag for direction collision resolution.
FlxObject
 InheritedcollideRight : Boolean
Flag for direction collision resolution.
FlxObject
 InheritedcollideTop : Boolean
Flag for direction collision resolution.
FlxObject
 InheritedcolOffsets : Array
An array of FlxPoint objects.
FlxObject
 InheritedcolVector : FlxPoint
These store a couple of useful numbers for speeding up collision resolution.
FlxObject
 Inheriteddead : Boolean
Handy for tracking gameplay or animations.
FlxObject
 Inheriteddrag : FlxPoint
This isn't drag exactly, more like deceleration that is only applied when acceleration is not affecting the sprite.
FlxObject
 Inheritedexists : Boolean
Kind of a global on/off switch for any objects descended from FlxObject.
FlxObject
 Inheritedfixed : Boolean
If an object is 'fixed' in space, it will not budge when it collides with a not-fixed object.
FlxObject
 Inherited_group : Boolean
Dedicated internal flag for whether or not this class is a FlxGroup.
FlxObject
 Inheritedhealth : Number
Handy for storing health percentage or armor points or whatever.
FlxObject
 Inheritedheight : Number
FlxRect
  ID : int
FlxGroup
 Inheritedleft : Number
[read-only] The X coordinate of the left side of the rectangle.
FlxRect
 InheritedmaxAngular : Number
Use in conjunction with angularAcceleration for fluid spin speed control.
FlxObject
 InheritedmaxThrust : Number
Used to cap thrust, helpful and easy!
FlxObject
 InheritedmaxVelocity : 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 FlxObjects that exist in this layer.
FlxGroup
 Inheritedmoves : Boolean
Set this to false if you want to skip the automatic motion/movement stuff (see updateMotion()).
FlxObject
  name : String
FlxGroup
 InheritedonFloor : Boolean
Flag that indicates whether or not you just hit the floor.
FlxObject
 Inheritedorigin : FlxPoint
WARNING: The origin of the sprite will default to its center.
FlxObject
 Inheritedright : Number
[read-only] The X coordinate of the right side of the rectangle.
FlxRect
 InheritedscrollFactor : 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
 Inheritedsolid : Boolean
If an object is dead, the functions that automate collisions will skip it (see FlxG.overlapArrays() and FlxG.collideArrays()).
FlxObject
 Inheritedthrust : Number
If you want to do Asteroids style stuff, check out thrust, instead of directly accessing the object's velocity or acceleration.
FlxObject
 Inheritedtop : Number
[read-only] The Y coordinate of the top of the rectangle.
FlxRect
 Inheritedvelocity : FlxPoint
The basic speed of this object.
FlxObject
 Inheritedvisible : Boolean
If an object is not visible, the game loop will not automatically call render() on it.
FlxObject
 Inheritedwidth : Number
FlxRect
 Inheritedx : Number
FlxPoint
 Inheritedy : Number
FlxPoint
Protected Properties
 PropertyDefined By
  _first : Boolean
FlxGroup
 Inherited_flashPoint : Point
This is a pre-allocated Flash Point object, which is useful for certain Flash graphics API calls
FlxObject
 Inherited_flicker : Boolean
Internal helper used for retro-style flickering.
FlxObject
 Inherited_flickerTimer : Number
Internal helper used for retro-style flickering.
FlxObject
  _last : FlxPoint
Helpers for moving/updating group members.
FlxGroup
 Inherited_point : FlxPoint
This is just a pre-allocated x-y point container to be used however you like
FlxObject
 Inherited_rect : FlxRect
This is just a pre-allocated rectangle container to be used however you like
FlxObject
Public Methods
 MethodDefined By
  
Constructor
FlxGroup
  
add(Object:FlxObject, ShareScroll:Boolean = false):FlxObject
Adds a new FlxObject subclass (FlxSprite, FlxBlock, etc) to the list of children
FlxGroup
 Inherited
collide(Object:FlxObject = null):Boolean
FlxObject
  
countDead():int
Call this function to find out how many members of the group are dead.
FlxGroup
  
Call this function to find out how many members of the group are not dead.
FlxGroup
  
Returns a count of how many objects in this group are on-screen right now.
FlxGroup
  
destroy():void
[override] Override this function to handle any deleting or "shutdown" type operations you might need, such as removing traditional Flash children like Sprite objects.
FlxGroup
 Inherited
flicker(Duration:Number = 1):void
Tells this object to flicker, retro-style.
FlxObject
 Inherited
flickering():Boolean
Check to see if the object is still flickering.
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
  
Call this function to retrieve the first index set to 'null'.
FlxGroup
  
Returns a member at random from the group.
FlxGroup
 Inherited
Call this function to figure out the on-screen position of the object.
FlxObject
 Inherited
hitBottom(Contact:FlxObject, Velocity:Number):void
Called when this object's bottom edge collides with the top of another FlxObject.
FlxObject
 Inherited
hitLeft(Contact:FlxObject, Velocity:Number):void
Called when this object's left side collides with another FlxObject's right.
FlxObject
 Inherited
hitRight(Contact:FlxObject, Velocity:Number):void
Called when this object's right side collides with another FlxObject's left.
FlxObject
 Inherited
hitTop(Contact:FlxObject, Velocity:Number):void
Called when this object's top collides with the bottom of another FlxObject.
FlxObject
 Inherited
hurt(Damage:Number):void
Call this function to "damage" (or give health bonus) to this sprite.
FlxObject
  
kill():void
[override] Calls kill on the group and all its members.
FlxGroup
 Inherited
onScreen():Boolean
Check and see if this object is currently on screen.
FlxObject
 Inherited
overlaps(Object:FlxObject):Boolean
Checks to see if some FlxObject object overlaps this FlxObject object.
FlxObject
 Inherited
overlapsPoint(X:Number, Y:Number, PerPixel:Boolean = false):Boolean
Checks to see if a point in 2D space overlaps this FlxObject object.
FlxObject
 Inherited
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
 Inherited
Called by FlxObject.updateMotion() and some constructors to rebuild the basic collision data for this object.
FlxObject
  
remove(Object:FlxObject, Splice:Boolean = false):FlxObject
Removes an object from the group.
FlxGroup
  
render():void
[override] Automatically goes through and calls render on everything you added, override this loop to control render order manually.
FlxGroup
  
replace(OldObject:FlxObject, NewObject:FlxObject):FlxObject
Replaces an existing FlxObject with a new one.
FlxGroup
  
reset(X:Number, Y:Number):void
[override] 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
  
toString():String
[override]
FlxGroup
  
update():void
[override] Automatically goes through and calls update on everything you added, override this function to handle custom input and perform collisions.
FlxGroup
Protected Methods
 MethodDefined By
  
Internal function that actually loops through and destroys each member.
FlxGroup
  
Internal function that calls kill on all members.
FlxGroup
  
Internal function that actually loops through and renders all the group members.
FlxGroup
  
Internal function, helps with the moving/updating of group members.
FlxGroup
 Inherited
Just updates the retro-style flickering.
FlxObject
  
Internal function that actually goes through and updates all the group members.
FlxGroup
 Inherited
Internal function for updating the position and speed of this object.
FlxObject
Protected Constants
 ConstantDefined By
 Inherited_pZero : FlxPoint
[static] A handy "empty point" object
FlxObject
Property Detail
_firstproperty
protected var _first:Boolean

_lastproperty 
protected var _last:FlxPoint

Helpers for moving/updating group members.

IDproperty 
public var ID:int

membersproperty 
public var members:Array

Array of all the FlxObjects that exist in this layer.

nameproperty 
public var name:String

Constructor Detail
FlxGroup()Constructor
public function FlxGroup()

Constructor

Method Detail
add()method
public function add(Object:FlxObject, ShareScroll:Boolean = false):FlxObject

Adds a new FlxObject subclass (FlxSprite, FlxBlock, etc) to the list of children

Parameters

Object:FlxObject — The object you want to add
 
ShareScroll:Boolean (default = false) — Whether or not this FlxCore should sync up with this layer's scrollFactor

Returns
FlxObject — The same FlxCore 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.

Returns
int — The number of FlxObjects 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.

Returns
int — The number of FlxObjects 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.

Returns
int — The number of FlxObjects that are on screen. Returns -1 if group is empty.
destroy()method 
override public 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.

Returns
FlxObject — 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.

Returns
FlxObject — 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.

Returns
FlxObject — 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.

Returns
FlxObject — 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.

Returns
int — An int indicating the first null slot in the group.
getRandom()method 
public function getRandom():FlxObject

Returns a member at random from the group.

Returns
FlxObject — A FlxObject from the members list.
kill()method 
override public 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.

Parameters

Object:FlxObject — The FlxObject you want to remove.
 
Splice:Boolean (default = false) — Whether the object should be cut from the array entirely or not.

Returns
FlxObject — The removed object.
render()method 
override public 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.

Parameters

OldObject:FlxObject — The object you want to replace.
 
NewObject:FlxObject — The new object you want to use instead.

Returns
FlxObject — The new object.
reset()method 
override public function reset(X:Number, Y:Number):void

If the group's position is reset, we want to reset all its members too.

Parameters

X: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.

Parameters

X:Number (default = 0) — The new X position of this object.
 
Y:Number (default = 0) — The new Y position of this object.

Returns
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.

toString()method 
override public function toString():String

Returns
String
update()method 
override public 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.