[ flixel ] SEARCH!
Packages

- com.adamatomic.flixel.data
- com.adamatomic.flixel

com.adamatomic.flixel.data classes

- FlxAnim
- FlxFactory
- FlxLogoPixel

com.adamatomic.flixel classes

- FlxArray
- FlxBlock
- FlxButton
- FlxCore
- FlxEmitter
- FlxG
- FlxGame
- FlxLayer
- FlxSprite
- FlxState
- FlxText
- FlxTilemap

FlxAnim
Description
Just a helper structure for the FlxSprite animation system
Members

- name
- delay
- frames
- looped

Functions

- FlxAnim

FlxFactory
Description
This class handles the 8-bit style preloader
Members

- className
- myURL

Functions

- FlxFactory

FlxLogoPixel
Description
This automates the color-rotation effect on the 'f' logo during game launch, not used in actual game code
Functions

- FlxLogoPixel
- update

FlxArray
Description
This class wraps the normal Flash array and adds a couple of extra functions...
Functions

- FlxArray
- getRandom
- getNonexist
- add
- remove
- removeAt
- kill
- killAt
- clear

FlxBlock
Description
This is the basic "environment object" class, used to create walls and floors
Functions

- FlxBlock
- render

FlxButton
Description
A simple button class that calls a function when mouse-clicked
Functions

- FlxButton
- update
- render
- switchOff
- switchOn
- on

FlxCore
Description
This is the base class for most of the display objects (FlxSprite, FlxText, etc). It includes some very simple basic attributes about game objects.
Members

- exists
- active
- visible
- dead
- x
- y
- width
- height
- scrollFactor

Functions

- FlxCore
- update
- render
- overlaps
- overlapsPoint
- collide
- hitWall
- hitFloor
- hitCeiling
- kill
- flicker
- flickering
- onScreen

FlxEmitter
Description
A simple particle system class
Members

- minVelocity
- maxVelocity

Functions

- FlxEmitter
- update
- reset
- emit
- kill

FlxG
Description
This is a global helper class full of useful functions for audio, input, basic info, and the camera system
Members

- elapsed
- state
- width
- height
- level
- levels
- score
- scores
- kUp
- kDown
- kLeft
- kRight
- kA
- kB
- kMouse
- mouse
- followTarget
- followLead
- followLerp
- followMin
- followMax
- scroll
- buffer

Functions

- resetKeys
- pressed
- justPressed
- justReleased
- setMusic
- play
- playMusic
- pauseMusic
- stopMusic
- setMute
- getMute
- setVolume
- getVolume
- setMusicVolume
- getMusicVolume
- createBitmap
- addBitmap
- rotatePoint
- getAngle
- follow
- followAdjust
- followBounds
- computeVelocity
- overlapArray
- overlapArrays
- collideArray
- collideArray2
- collideArrays
- switchState
- log
- quake
- flash
- fade
- setCursor
- openURL

FlxGame
Description
This function is only used by the FlxGame class to do important internal management stuff
Functions

- FlxGame

FlxLayer
Description
This is an organizational class that can update and render a bunch of FlxCore objects
Functions

- FlxLayer
- add
- update
- render
- destroy

FlxSprite
Description
The main "game object" class, handles basic physics and animation
Members

- offset
- velocity
- acceleration
- drag
- maxVelocity
- angle
- angularVelocity
- angularAcceleration
- angularDrag
- maxAngular
- thrust
- maxThrust
- health
- scale
- finished
- _curAnim
- _curFrame
- pixels

Functions

- FlxSprite
- update
- render
- overlapsPoint
- hitWall
- hitFloor
- hitCeiling
- hurt
- onEmit
- addAnimation
- addAnimationCallback
- play
- randomFrame
- specificFrame

FlxState
Description
This is the basic game "state" object - e.g. in a simple game you might have a menu state and a play state
Functions

- FlxState
- add
- update
- render
- destroy

FlxText
Description
A basic text display class, can do some fun stuff though like flicker and rotate
Members

- angle

Functions

- FlxText
- setText
- setColor
- update
- render

FlxTilemap
Description
This is a traditional tilemap display and collision class
Functions

- FlxTilemap
- render
- collide

FlxAnim
function FlxAnim (Name : String, Frames : Array, FrameRate : Number, Looped : Boolean) :
Description
Constructor.
Parameters
Name
:
String
What this animation should be called (e.g. "run")
Frames
:
Array
An array of numbers indicating what frames to play in what order (e.g. 1, 2, 3)
FrameRate
:
Number
The speed in frames per second that the animation should play at (e.g. 40 fps)
Looped
:
Boolean
Whether or not the animation is looped or just plays once
name
name : String
delay
delay : Number
frames
frames : Array
looped
looped : Boolean
FlxFactory
function FlxFactory () :
className
className : String
Description
This should always be the name of your main project/document class (e.g. GravityHook).
myURL
myURL : String
Description
If you want to use site-locking, set your website URL here.
FlxLogoPixel
function FlxLogoPixel (xPos : int, yPos : int, pixelSize : uint, index : uint, finalColor : uint) :
Parameters
xPos
:
int
No info.
yPos
:
int
No info.
pixelSize
:
uint
No info.
index
:
uint
No info.
finalColor
:
uint
No info.
update
function update () : void
FlxArray
function FlxArray () :
Description
Constructor.
getRandom
function getRandom (Arr : Array) : Object
Description
Picks an entry at random from an array.
Parameters
Arr
:
Array
The array you want to pick the object from
getNonexist
function getNonexist () : FlxCore
Description
Find the first entry in the array that doesn't "exist".
add
function add (Obj : Object) : Object
Description
Add an object to this array.
Parameters
Obj
:
Object
The object you want to add to the array
remove
function remove (Obj : Object, Splice : Boolean) : void
Description
Remove any object from this array.
Parameters
Obj
:
Object
No info.
Splice
:
Boolean
No info.
removeAt
function removeAt (Index : uint, Splice : Boolean) : void
Description
Remove any object from this array.
Parameters
Index
:
uint
The entry in the array that you want to remove
Splice
:
Boolean
No info.
kill
function kill (Core : FlxCore) : void
Description
Kills the specified FlxCore-based object (FlxSprite, FlxText, etc) in this array.
Parameters
Core
:
FlxCore
The object you want to kill
killAt
function killAt (Index : uint) : void
Description
Kills the specified FlxCore-based object (FlxSprite, FlxText, etc) in this array.
Parameters
Index
:
uint
The entry in the array that you want to kill
clear
function clear () : void
Description
Pops every entry out of the array.
FlxBlock
function FlxBlock (X : int, Y : int, Width : uint, Height : uint, TileGraphic : Class, Empties : uint) :
Description
Constructor.
Parameters
X
:
int
The X position of the block
Y
:
int
The Y position of the block
Width
:
uint
The width of the block
Height
:
uint
The height of the block
TileGraphic
:
Class
The graphic class that contains the tiles that should fill this block
Empties
:
uint
The number of "empty" tiles to add to the auto-fill algorithm (e.g. 8 tiles + 4 empties = 1
render
function render () : void
Description
Draws this block.
FlxButton
function FlxButton (X : int, Y : int, Image : FlxSprite, Callback : Function, ImageOn : FlxSprite, Text : FlxText, TextOn : FlxText) :
Description
Constructor.
Parameters
X
:
int
The X position of the button
Y
:
int
The Y position of the button
Image
:
FlxSprite
A FlxSprite object to use for the button background
Callback
:
Function
The function to call whenever the button is clicked
ImageOn
:
FlxSprite
A FlxSprite object to use for the button background when highlighted (optional)
Text
:
FlxText
A FlxText object to use to display text on this button (optional)
TextOn
:
FlxText
A FlxText object that is used when the button is highlighted (optional)
update
function update () : void
Description
Called by the game loop automatically, handles mouseover and click detection.
render
function render () : void
switchOff
function switchOff () : void
Description
Call this function from your callback to toggle the button off, like a checkbox.
switchOn
function switchOn () : void
Description
Call this function from your callback to toggle the button on, like a checkbox.
on
function on () : Boolean
Description
Check to see if the button is toggled on, like a checkbox.
FlxCore
function FlxCore () :
Description
Constructor.
update
function update () : void
Description
Just updates the flickering. FlxSprite and other subclasses override this to do more complicated behavior..
render
function render () : void
Description
FlxSprite and other subclasses override this to render their materials to the screen.
overlaps
function overlaps (Core : FlxCore) : Boolean
Description
Checks to see if some FlxCore object overlaps this FlxCore object.
Parameters
Core
:
FlxCore
The object being tested
overlapsPoint
function overlapsPoint (X : Number, Y : Number, PerPixel : Boolean) : Boolean
Description
Checks to see if a point in 2D space overlaps this FlxCore object.
Parameters
X
:
Number
The X coordinate of the point
Y
:
Number
The Y coordinate of the point
PerPixel
:
Boolean
Whether or not to use per pixel collision checking (only available in FlxSprite subclass, included here because of Flash's F'd up lack of polymorphism)
collide
function collide (Spr : FlxSprite) : void
Description
Collides a FlxSprite against this block.
Parameters
Spr
:
FlxSprite
The FlxSprite you want to collide
hitWall
function hitWall () : Boolean
Description
Called when this object collides with a FlxBlock on one of its sides.
hitFloor
function hitFloor () : Boolean
Description
Called when this object collides with the top of a FlxBlock.
hitCeiling
function hitCeiling () : Boolean
Description
Called when this object collides with the bottom of a FlxBlock.
kill
function kill () : void
Description
Call this function to "kill" a sprite so that it no longer 'exists'.
flicker
function flicker (Duration : Number) : void
Description
Tells this object to flicker for the number of seconds requested (0 = infinite, negative number tells it to stop).
Parameters
Duration
:
Number
No info.
flickering
function flickering () : Boolean
Description
Called when this object collides with the bottom of a FlxBlock.
onScreen
function onScreen () : Boolean
Description
Call this to check and see if this object is currently on screen.
exists
exists : Boolean
Description
Kind of a global on/off switch for any objects descended from FlxCore.
active
active : Boolean
Description
If an object is not alive, the game loop will not automatically call update() on it.
visible
visible : Boolean
Description
If an object is not visible, the game loop will not automatically call render() on it.
dead
dead : Boolean
Description
If an object is dead, the functions that automate collisions will skip it (see overlapArrays in FlxSprite and collideArrays in FlxBlock).
x
x : Number
y
y : Number
width
width : uint
height
height : uint
scrollFactor
scrollFactor : Point
Description
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 tthe same speed as the foreground layer..
FlxEmitter
function FlxEmitter (X : Number, Y : Number, Width : uint, Height : uint, Sprites : FlxArray, Delay : Number, MinVelocityX : Number, MaxVelocityX : Number, MinVelocityY : Number, MaxVelocityY : Number, MinRotation : Number, MaxRotation : Number, Gravity : Number, Drag : Number, Graphics : Class, Quantity : uint, Multiple : Boolean, Parent : FlxLayer) :
Description
Constructor.
Parameters
X
:
Number
The X position of the emitter
Y
:
Number
The Y position of the emitter
Width
:
uint
The width of the emitter (particles are emitted from a random position inside this box)
Height
:
uint
The height of the emitter
Sprites
:
FlxArray
A pre-configured FlxArray of FlxSprite objects for the emitter to use (optional)
Delay
:
Number
A negative number defines the lifespan of the particles that are launched all at once. A positive number tells it how often to fire a new particle.
MinVelocityX
:
Number
The minimum X velocity of the particles
MaxVelocityX
:
Number
The maximum X velocity of the particles (every particle will have a random X velocity between these values)
MinVelocityY
:
Number
The minimum Y velocity of the particles
MaxVelocityY
:
Number
The maximum Y velocity of the particles (every particle will have a random Y velocity between these values)
MinRotation
:
Number
The minimum angular velocity of the particles
MaxRotation
:
Number
The maximum angular velocity of the particles (you guessed it)
Gravity
:
Number
How much gravity should affect the particles
Drag
:
Number
Sets both the X and Y "Drag" or deceleration on the particles
Graphics
:
Class
If you opted to not pre-configure an array of FlxSprite objects, you can simply pass in a particle image or sprite sheet (ignored if you pass in an array)
Quantity
:
uint
The number of particles to generate when using the "create from image" option (ignored if you pass in an array)
Multiple
:
Boolean
Whether the image in the Graphics param is a single particle or a bunch of particles (if it's a bunch, they need to be square!)
Parent
:
FlxLayer
No info.
update
function update () : void
Description
Called automatically by the game loop, decides when to launch particles and when to "die".
reset
function reset () : void
Description
Call this function to reset the emitter (if you used a negative delay, calling this function "Explodes" the emitter again).
emit
function emit () : void
Description
This function can be used both internally and externally to emit the next particle.
kill
function kill () : void
Description
Call this function to turn off all the particles and the emitter.
minVelocity
minVelocity : Point
maxVelocity
maxVelocity : Point
resetKeys
function resetKeys () : void
Description
Resets the key register and shortcut booleans to "off".
pressed
function pressed (Key : uint) : Boolean
Description
Check to see if this key is pressed.
Parameters
Key
:
uint
One of the key constants listed above (e.g. LEFT or A)
justPressed
function justPressed (Key : uint) : Boolean
Description
Check to see if this key was JUST pressed.
Parameters
Key
:
uint
One of the key constants listed above (e.g. LEFT or A)
justReleased
function justReleased (Key : uint) : Boolean
Description
Check to see if this key is NOT pressed.
Parameters
Key
:
uint
One of the key constants listed above (e.g. LEFT or A)
setMusic
function setMusic (Music : Class, Volume : Number, Autoplay : Boolean) : void
Description
Set up and autoplay a music track.
Parameters
Music
:
Class
The sound file you want to loop in the background
Volume
:
Number
How loud the sound should be, from 0 to 1
Autoplay
:
Boolean
Whether to automatically start the music or not (defaults to true)
play
function play (SoundEffect : Class, Volume : Number) : void
Description
Plays a sound effect once.
Parameters
SoundEffect
:
Class
The sound you want to play
Volume
:
Number
How loud to play it (0 to 1)
playMusic
function playMusic () : void
Description
Plays or resumes the music file set up using setMusic().
pauseMusic
function pauseMusic () : void
Description
Pauses the current music track.
stopMusic
function stopMusic () : void
Description
Stops the current music track.
setMute
function setMute (SoundOff : Boolean) : void
Description
Mutes the sound.
Parameters
SoundOff
:
Boolean
Whether the sound should be off or on
getMute
function getMute () : Boolean
Description
Check to see if the game is muted.
setVolume
function setVolume (Volume : Number) : void
Description
Change the volume of the game.
Parameters
Volume
:
Number
A number from 0 to 1
getVolume
function getVolume () : Number
Description
Find out how load the game is currently.
setMusicVolume
function setMusicVolume (Volume : Number) : void
Description
Change the volume of just the music.
Parameters
Volume
:
Number
A number from 0 to 1
getMusicVolume
function getMusicVolume () : Number
Description
Find out how loud the music is.
createBitmap
function createBitmap (Width : uint, Height : uint, Color : uint) : BitmapData
Description
Generates a new BitmapData object (basically a colored square :P) and caches it.
Parameters
Width
:
uint
How wide the square should be
Height
:
uint
How high the square should be
Color
:
uint
What color the square should be
addBitmap
function addBitmap (Graphic : Class, Reverse : Boolean) : BitmapData
Description
Loads a bitmap from a file, caches it, and generates a horizontally flipped version if necessary.
Parameters
Graphic
:
Class
The image file that you want to load
Reverse
:
Boolean
Whether to generate a flipped version
rotatePoint
function rotatePoint (X : Number, Y : Number, PivotX : Number, PivotY : Number, Angle : Number) : Point
Description
Rotates a point in 2D space around another point by the given angle.
Parameters
X
:
Number
The X coordinate of the point you want to rotate
Y
:
Number
The Y coordinate of the point you want to rotate
PivotX
:
Number
The X coordinate of the point you want to rotate around
PivotY
:
Number
The Y coordinate of the point you want to rotate around
Angle
:
Number
Rotate the point by this many degrees
getAngle
function getAngle (X : Number, Y : Number) : Number
Description
Calculates the angle between a point and the origin (0,0).
Parameters
X
:
Number
The X coordinate of the point
Y
:
Number
The Y coordinate of the point
follow
function follow (Target : FlxCore, Lerp : Number) : void
Description
Tells the camera subsystem what FlxCore object to follow.
Parameters
Target
:
FlxCore
The object to follow
Lerp
:
Number
How much lag the camera should have (can help smooth out the camera movement)
followAdjust
function followAdjust (LeadX : Number, LeadY : Number) : void
Description
Specify an additional camera component - the velocity-based "lead", or amount the camera should track in front of a sprite.
Parameters
LeadX
:
Number
Percentage of X velocity to add to the camera's motion
LeadY
:
Number
Percentage of Y velocity to add to the camera's motion
followBounds
function followBounds (MinX : int, MinY : int, MaxX : int, MaxY : int) : void
Description
Specify an additional camera component - the boundaries of the level or where the camera is allowed to move.
Parameters
MinX
:
int
The smallest X value of your level (usually 0)
MinY
:
int
The smallest Y value of your level (usually 0)
MaxX
:
int
The largest X value of your level (usually the level width)
MaxY
:
int
The largest Y value of your level (usually the level height)
computeVelocity
function computeVelocity (Velocity : Number, Acceleration : Number, Drag : Number, Max : Number) : Number
Description
A fairly stupid tween-like function that takes a starting velocity and some other factors and returns an altered velocity.
Parameters
Velocity
:
Number
Any component of velocity (e.g. 20)
Acceleration
:
Number
Rate at which the velocity is changing
Drag
:
Number
Really kind of a deceleration, this is how much the velocity changes if Acceleration is not set
Max
:
Number
An absolute value cap for the velocity
overlapArray
function overlapArray (Array : FlxArray, Core : FlxCore, Collide : Function) : void
Description
Checks to see if a FlxCore overlaps any of the FlxCores in the array, and calls a function when they do.
Parameters
Array
:
FlxArray
An array of FlxCore objects
Core
:
FlxCore
A FlxCore object
Collide
:
Function
A function that takes two sprites as parameters (first the one from Array, then Sprite)
overlapArrays
function overlapArrays (Array1 : FlxArray, Array2 : FlxArray, Collide : Function) : void
Description
Checks to see if any FlxCore in Array1 overlaps any FlxCore in Array2, and calls Collide when they do.
Parameters
Array1
:
FlxArray
An array of FlxCore objects
Array2
:
FlxArray
Another array of FlxCore objects
Collide
:
Function
A function that takes two FlxCore objects as parameters (first the one from Array1, then the one from Array2)
collideArray
function collideArray (Cores : FlxArray, Sprite : FlxSprite) : void
Description
Collides a FlxSprite against the FlxCores in the array .
Parameters
Cores
:
FlxArray
No info.
Sprite
:
FlxSprite
A FlxSprite object
collideArray2
function collideArray2 (Core : FlxCore, Sprites : FlxArray) : void
Description
Collides an array of FlxSprites against a FlxCore object.
Parameters
Core
:
FlxCore
A FlxCore object
Sprites
:
FlxArray
An array of FlxSprites
collideArrays
function collideArrays (Cores : FlxArray, Sprites : FlxArray) : void
Description
Collides the array of FlxSprites against the array of FlxCores.
Parameters
Cores
:
FlxArray
An array of FlxCore objects
Sprites
:
FlxArray
An array of FlxSprite objects
switchState
function switchState (State : Class) : void
Description
Switch from one FlxState to another.
Parameters
State
:
Class
The class name of the state you want (e.g. PlayState)
log
function log (Data : String) : void
Description
Log data to the developer console.
Parameters
Data
:
String
The data (in string format) that you wanted to write to the console
quake
function quake (Intensity : Number, Duration : Number) : void
Description
Shake the screen.
Parameters
Intensity
:
Number
Percentage of screen size representing the maximum distance that the screen can move during the 'quake'
Duration
:
Number
The length in seconds that the "quake" should last
flash
function flash (Color : uint, Duration : Number, FlashComplete : Function, Force : Boolean) : void
Description
Temporarily fill the screen with a certain color, then fade it out.
Parameters
Color
:
uint
The color you want to use
Duration
:
Number
How long it takes for the flash to fade
FlashComplete
:
Function
A function you want to run when the flash finishes
Force
:
Boolean
Force the effect to reset
fade
function fade (Color : uint, Duration : Number, FadeComplete : Function, Force : Boolean) : void
Description
Fade the screen out to this color.
Parameters
Color
:
uint
The color you want to use
Duration
:
Number
How long it should take to fade the screen out
FadeComplete
:
Function
A function you want to run when the fade finishes
Force
:
Boolean
Force the effect to reset
setCursor
function setCursor (CursorGraphic : Class) : void
Description
Set the mouse cursor to some graphic file.
Parameters
CursorGraphic
:
Class
The image you want to use for the cursor
openURL
function openURL (URL : String) : void
Description
Switch to a different web page.
Parameters
URL
:
String
No info.
elapsed
elapsed : Number
Description
Represents the amount of time in seconds that passed since last frame.
state
state : FlxState
Description
A reference or pointer to the current FlxState object being used by the game.
width
width : uint
height
height : uint
level
level : uint
levels
levels : FlxArray
score
score : uint
scores
scores : FlxArray
kUp
kUp : Boolean
Description
A shortcut way of checking if a particular key is pressed.
kDown
kDown : Boolean
Description
A shortcut way of checking if a particular key is pressed.
kLeft
kLeft : Boolean
Description
A shortcut way of checking if a particular key is pressed.
kRight
kRight : Boolean
Description
A shortcut way of checking if a particular key is pressed.
kA
kA : Boolean
Description
A shortcut way of checking if a particular key is pressed.
kB
kB : Boolean
Description
A shortcut way of checking if a particular key is pressed.
kMouse
kMouse : Boolean
Description
A shortcut way of checking if a particular key is pressed.
mouse
mouse : Point
Description
The current game coordinates of the mouse pointer (not necessarily the screen coordinates).
followTarget
followTarget : FlxCore
followLead
followLead : Point
followLerp
followLerp : Number
followMin
followMin : Point
followMax
followMax : Point
scroll
scroll : Point
buffer
buffer : BitmapData
FlxGame
function FlxGame (GameSizeX : uint, GameSizeY : uint, InitialState : Class, Zoom : uint, BGColor : Number, ShowFlixelLogo : Boolean, FlixelColor : Number, FlixelSound : Class, Frame : Class, ScreenOffsetX : uint, ScreenOffsetY : uint) :
Description
Constructor.
Parameters
GameSizeX
:
uint
The width of your game in pixels (e.g. 320)
GameSizeY
:
uint
The height of your game in pixels (e.g. 240)
InitialState
:
Class
The class name of the state you want to create and switch to first (e.g. MenuState)
Zoom
:
uint
The level of zoom (e.g. 2 means all pixels are now rendered twice as big)
BGColor
:
Number
The color of the Flash app's background
ShowFlixelLogo
:
Boolean
No info.
FlixelColor
:
Number
The color of the great big 'f' in the flixel logo
FlixelSound
:
Class
The sound that is played over the flixel 'f' logo
Frame
:
Class
If you want you can add a little graphical frame to the outside edges of your game
ScreenOffsetX
:
uint
If you use a frame, you're probably going to want to scoot your game down to fit properly inside it
ScreenOffsetY
:
uint
These variables do exactly that!
FlxLayer
function FlxLayer () :
Description
Constructor .
add
function add (Core : FlxCore) : FlxCore
Description
Adds a new FlxCore subclass (FlxSprite, FlxBlock, etc) to the list of children.
Parameters
Core
:
FlxCore
The object you want to add
update
function update () : void
Description
Automatically goes through and calls update on everything you added, override this function to handle custom input and perform collisions.
render
function render () : void
Description
Automatically goes through and calls render on everything you added, override this loop to do crazy graphical stuffs I guess?.
destroy
function destroy () : void
Description
Override this function to handle any deleting or "shutdown" type operations you might need (such as removing traditional Flash children like Sprite objects).
FlxSprite
function FlxSprite (Graphic : Class, X : int, Y : int, Animated : Boolean, Reverse : Boolean, Width : uint, Height : uint, Color : uint) :
Description
Constructor.
Parameters
Graphic
:
Class
The image you want to use
X
:
int
The initial X position of the sprite
Y
:
int
The initial Y position of the sprite
Animated
:
Boolean
Whether the Graphic parameter is a single sprite or a row of sprites
Reverse
:
Boolean
Whether you need this class to generate horizontally flipped versions of the animation frames
Width
:
uint
If you opt to NOT use an image and want to generate a colored block, or your sprite's frames are not square, you can specify a width here
Height
:
uint
If you opt to NOT use an image you can specify the height of the colored block here (ignored if Graphic is not null)
Color
:
uint
Specifies the color of the generated block (ignored if Graphic is not null)
update
function update () : void
Description
Called by game loop, handles animation and physics.
render
function render () : void
Description
Called by game loop, blits current frame of animation to the screen (and handles rotation).
overlapsPoint
function overlapsPoint (X : Number, Y : Number, PerPixel : Boolean) : Boolean
Description
Checks to see if a point in 2D space overlaps this FlxCore object.
Parameters
X
:
Number
The X coordinate of the point
Y
:
Number
The Y coordinate of the point
PerPixel
:
Boolean
Whether or not to use per pixel collision checking
hitWall
function hitWall () : Boolean
Description
Called when this object collides with a FlxBlock on one of its sides.
hitFloor
function hitFloor () : Boolean
Description
Called when this object collides with the top of a FlxBlock.
hitCeiling
function hitCeiling () : Boolean
Description
Called when this object collides with the bottom of a FlxBlock.
hurt
function hurt (Damage : Number) : void
Description
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)
onEmit
function onEmit () : void
Description
Called if/when this sprite is launched by a FlxEmitter.
addAnimation
function addAnimation (Name : String, Frames : Array, FrameRate : Number, Looped : Boolean) : void
Description
Adds a new animation to the sprite.
Parameters
Name
:
String
What this animation should be called (e.g. "run")
Frames
:
Array
An array of numbers indicating what frames to play in what order (e.g. 1, 2, 3)
FrameRate
:
Number
The speed in frames per second that the animation should play at (e.g. 40 fps)
Looped
:
Boolean
Whether or not the animation is looped or just plays once
addAnimationCallback
function addAnimationCallback (AnimationCallback : Function) : void
Description
Pass in a function to be called whenever this sprite's animation changes.
Parameters
AnimationCallback
:
Function
A function that has 3 parameters: a string name, a uint frame number, and a uint frame index
play
function play (AnimName : String, Force : Boolean) : void
Description
Plays an existing animation (e.g. "run") - if you call an animation that is already playing it will be ignored.
Parameters
AnimName
:
String
The string name of the animation you want to play
Force
:
Boolean
Whether to force the animation to restart
randomFrame
function randomFrame () : void
Description
Tell the sprite to change to a random frame of animation (useful for instantiating particles or other weird things).
specificFrame
function specificFrame (Frame : uint) : void
Description
Tell the sprite to change to a specific frame of animation (useful for instantiating particles).
Parameters
Frame
:
uint
The frame you want to display
offset
offset : Point
Description
If you changed the size of your sprite object to shrink the bounding box, you might need to offset the new bounding box from the top-left corner of the sprite.
velocity
velocity : Point
acceleration
acceleration : Point
drag
drag : Point
Description
This isn't drag exactly, more like deceleration that is only applied when acceleration is not affecting the sprite.
maxVelocity
maxVelocity : Point
angle
angle : Number
Description
WARNING: rotating sprites decreases rendering performance for this sprite by a factor of 10x!.
angularVelocity
angularVelocity : Number
angularAcceleration
angularAcceleration : Number
angularDrag
angularDrag : Number
maxAngular
maxAngular : Number
thrust
thrust : Number
Description
If you want to do Asteroids style stuff, check out thrust (instead of directly accessing the object's velocity or acceleration).
maxThrust
maxThrust : Number
health
health : Number
scale
scale : Point
Description
Scale doesn't currently affect collisions automatically, you will need to adjust the width, height and offset manually. WARNING: scaling sprites decreases rendering performance for this sprite by a factor of 10x!.
finished
finished : Boolean
Description
Whether the current animation has finished its first (or only) loop.
_curAnim
_curAnim : FlxAnim
_curFrame
_curFrame : uint
pixels
pixels : BitmapData
FlxState
function FlxState () :
Description
Constructor .
add
function add (Core : FlxCore) : FlxCore
Description
Adds a new FlxCore subclass (FlxSprite, FlxBlock, etc) to the game loop.
Parameters
Core
:
FlxCore
The object you want to add to the game loop
update
function update () : void
Description
Automatically goes through and calls update on everything you added to the game loop, override this function to handle custom input and perform collisions.
render
function render () : void
Description
Automatically goes through and calls render on everything you added to the game loop, override this loop to do crazy graphical stuffs I guess?.
destroy
function destroy () : void
Description
Override this function to handle any deleting or "shutdown" type operations you might need (such as removing traditional Flash children like Sprite objects).
FlxText
function FlxText (X : Number, Y : Number, Width : uint, Height : uint, Text : String, Color : uint, Font : String, Size : uint, Justification : String, Angle : Number) :
Description
Constructor.
Parameters
X
:
Number
The X position of the text
Y
:
Number
The Y position of the text
Width
:
uint
The width of the text object
Height
:
uint
The height of the text object (eventually these may be unnecessary by leveraging text metrics, but I couldn't get it together for this release)
Text
:
String
The actual text you would like to display initially
Color
:
uint
The color of the text object
Font
:
String
The name of the font you'd like to use (pass null to use the built-in pixel font)
Size
:
uint
The size of the font (recommend using multiples of 8 for cleanest rendering)
Justification
:
String
Valid strings include "left", "center", and "right"
Angle
:
Number
How much the text should be rotated
setText
function setText (Text : String) : void
Description
Changes the text being displayed.
Parameters
Text
:
String
The new string you want to display
setColor
function setColor (Color : uint) : void
Description
Changes the color being used by the text.
Parameters
Color
:
uint
The new color you want to use
update
function update () : void
Description
Called by the game loop automatically, updates the position and angle of the text.
render
function render () : void
Description
Called by the game loop automatically, blits the text object to the screen.
angle
angle : Number
FlxTilemap
function FlxTilemap (MapData : String, TileGraphic : Class, CollisionIndex : uint, DrawIndex : uint) :
Description
Constructor.
Parameters
MapData
:
String
A string of comma and line-return delineated indices indicating what order the tiles should go in
TileGraphic
:
Class
All the tiles you want to use, arranged in a strip corresponding to the numbers in MapData
CollisionIndex
:
uint
The index of the first tile that should be treated as a hard surface
DrawIndex
:
uint
The index of the first tile that should actually be drawn
render
function render () : void
Description
Draws the tilemap.
collide
function collide (Spr : FlxSprite) : void
Description
Collides a FlxSprite against the tilemap.
Parameters
Spr
:
FlxSprite
The FlxSprite you want to collide