Package | org.flixel |
Class | public class FlxText |
Inheritance | FlxText FlxSprite FlxObject FlxBasic Object |
FlxSprite
to support rendering text.
Can tint, fade, rotate and scale just like a sprite.
Doesn't really animate though, as far as I know.
Also does nice pixel-perfect centering on pixel fonts
as long as they are only one liners.
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 | ||
alignment : String
The alignment of the font ("left", "right", or "center"). | FlxText | ||
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 | ||
alpha : Number
Set alpha to a number between 0 and 1 to change the opacity of the sprite. | FlxSprite | ||
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 | ||
antialiasing : Boolean
Controls whether the object is smoothed when rotated, affects performance. | FlxSprite | ||
blend : String
Blending modes, just like Photoshop or whatever. | FlxSprite | ||
cameras : Array
An array of camera objects that this object will use during draw(). | FlxBasic | ||
color : uint [override]
The color of the text being displayed. | FlxText | ||
dirty : Boolean
Set this flag to true to force the sprite to update during the draw() call. | FlxSprite | ||
drag : FlxPoint
This isn't drag exactly, more like deceleration that is only applied
when acceleration is not affecting the sprite. | FlxObject | ||
elasticity : Number
The bounciness of this object. | FlxObject | ||
exists : Boolean
Controls whether update() and draw() are automatically called by FlxState/FlxGroup. | FlxBasic | ||
facing : uint
Set facing using FlxSprite.LEFT,RIGHT,
UP, and DOWN to take advantage of
flipped sprites and/or just track player orientation more easily. | FlxSprite | ||
finished : Boolean
Whether the current animation has finished its first (or only) loop. | FlxSprite | ||
flickering : Boolean [read-only]
Check to see if the object is still flickering. | FlxObject | ||
font : String
The font used for this text. | FlxText | ||
frame : uint
Tell the sprite to change to a specific frame of animation. | FlxSprite | ||
frameHeight : uint
The height of the actual graphic or image being displayed (not necessarily the game object/bounding box). | FlxSprite | ||
framePixels : BitmapData
The actual Flash BitmapData object representing the current display state of the sprite. | FlxSprite | ||
frames : uint
The total number of frames in this image. | FlxSprite | ||
frameWidth : uint
The width of the actual graphic or image being displayed (not necessarily the game object/bounding box). | FlxSprite | ||
health : Number
Handy for storing health percentage or armor points or whatever. | FlxObject | ||
height : Number
The height of this object. | FlxObject | ||
ID : int
IDs seem like they could be pretty useful, huh?
They're not actually used for anything yet though. | FlxBasic | ||
ignoreDrawDebug : Boolean
Setting this to true will prevent the object from appearing
when the visual debug mode in the debugger overlay is toggled on. | FlxBasic | ||
immovable : Boolean
Whether an object will move/alter position after a collision. | FlxObject | ||
last : FlxPoint
Important variable for collision processing. | FlxObject | ||
mass : Number
The virtual mass of the object. | 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 | ||
offset : FlxPoint
If you changed the size of your sprite object after loading or making the graphic,
you might need to offset the graphic away from the bound box to center it the way you want. | FlxSprite | ||
origin : FlxPoint
WARNING: The origin of the sprite will default to its center. | FlxSprite | ||
path : FlxPath
A reference to a path object. | FlxObject | ||
pathAngle : Number
The angle in degrees between this object and the next node, where 0 is directly upward, and 90 is to the right. | FlxObject | ||
pathSpeed : Number
The speed at which the object is moving on the path. | FlxObject | ||
pixels : BitmapData
Set pixels to any BitmapData object. | FlxSprite | ||
scale : FlxPoint
Change the size of your sprite's graphic. | FlxSprite | ||
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 | ||
shadow : uint
The color of the text shadow in 0xAARRGGBB hex format. | FlxText | ||
size : Number
The size of the text being displayed. | FlxText | ||
solid : Boolean
Whether the object collides or not. | FlxObject | ||
text : String
The text being displayed. | FlxText | ||
touching : uint
Bit field of flags (use with UP, DOWN, LEFT, RIGHT, etc) indicating surface contacts. | 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
Bit field of flags (use with UP, DOWN, LEFT, RIGHT, etc) indicating surface contacts from the previous game loop step. | FlxObject | ||
width : Number
The width of this object. | FlxObject | ||
x : Number
X position of the upper left corner of this object in world space. | FlxObject | ||
y : Number
Y position of the upper left corner of this object in world space. | FlxObject |
Property | Defined By | ||
---|---|---|---|
_alpha : Number
Internal tracker for opacity, used with Flash getter/setter. | FlxSprite | ||
_animations : Array
Internal, stores all the animations that were added to this sprite. | FlxSprite | ||
_bakedRotation : Number
Internal tracker for how many frames of "baked" rotation there are (if any). | FlxSprite | ||
_callback : Function
Internal tracker for the animation callback. | FlxSprite | ||
_color : uint
Internal tracker for color tint, used with Flash getter/setter. | FlxSprite | ||
_colorTransform : ColorTransform
Internal, helps with animation, caching and drawing. | FlxSprite | ||
_curAnim : FlxAnim
Internal, keeps track of the current animation being played. | FlxSprite | ||
_curFrame : uint
Internal, keeps track of the current frame of animation. | FlxSprite | ||
_curIndex : uint
Internal, keeps track of the current index into the tile sheet based on animation or rotation. | FlxSprite | ||
_facing : uint
Internal tracker for what direction the sprite is currently facing, used with Flash getter/setter. | FlxSprite | ||
_flashPoint : Point
Internal, reused frequently during drawing and animating. | FlxSprite | ||
_flashPointZero : Point
Internal, reused frequently during drawing and animating. | FlxSprite | ||
_flashRect : Rectangle
Internal, reused frequently during drawing and animating. | FlxSprite | ||
_flashRect2 : Rectangle
Internal, reused frequently during drawing and animating. | FlxSprite | ||
_flicker : Boolean
Internal helper used for retro-style flickering. | FlxObject | ||
_flickerTimer : Number
Internal helper used for retro-style flickering. | FlxObject | ||
_flipped : uint
Internal, keeps track of whether the sprite was loaded with support for automatic reverse/mirroring. | FlxSprite | ||
_frameTimer : Number
Internal, used to time each frame of animation. | FlxSprite | ||
ImgDefault : Class | FlxSprite | ||
_matrix : Matrix
Internal, helps with animation, caching and drawing. | FlxSprite | ||
_pathInc : int
Internal helper for node navigation, specifically yo-yo and backwards movement. | FlxObject | ||
_pathMode : uint
Internal tracker for path behavior flags (like looping, horizontal only, etc). | FlxObject | ||
_pathNodeIndex : int
Internal helper, tracks which node of the path this object is moving toward. | FlxObject | ||
_pathRotate : Boolean
Internal flag for whether hte object's angle should be adjusted to the path angle during path follow behavior. | FlxObject | ||
_pixels : BitmapData
Internal, stores the entire source graphic (not the current displayed animation frame), used with Flash getter/setter. | FlxSprite | ||
_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 | ||
_regen : Boolean
Whether the actual text field needs to be regenerated and stamped again. | FlxText | ||
_shadow : uint
Internal tracker for the text shadow color, default is clear/transparent. | FlxText | ||
_textField : TextField
Internal reference to a Flash TextField object. | FlxText |
Method | Defined By | ||
---|---|---|---|
FlxText(X:Number, Y:Number, Width:uint, Text:String = null, EmbeddedFont:Boolean = true)
Creates a new FlxText object at the specified position. | FlxText | ||
addAnimation(Name:String, Frames:Array, FrameRate:Number = 0, Looped:Boolean = true):void
Adds a new animation to the sprite. | FlxSprite | ||
addAnimationCallback(AnimationCallback:Function):void
Pass in a function to be called whenever this sprite's animation changes. | FlxSprite | ||
centerOffsets(AdjustPosition:Boolean = false):void
Helper function that adjusts the offset automatically to center the bounding box within the graphic. | FlxSprite | ||
destroy():void [override]
Clean up memory. | FlxText | ||
draw():void [override]
Called by game loop, updates then blits or renders current frame of animation to the screen
| FlxSprite | ||
[override]
Override this function to draw custom "debug mode" graphics to the
specified camera while the debugger's visual mode is toggled on. | FlxObject | ||
drawFrame(Force:Boolean = false):void
Request (or force) that the sprite update the frame before rendering. | FlxSprite | ||
drawLine(StartX:Number, StartY:Number, EndX:Number, EndY:Number, Color:uint, Thickness:uint = 1):void
This function draws a line on this sprite from position X1,Y1
to position X2,Y2 with the specified color. | FlxSprite | ||
fill(Color:uint):void
Fills this sprite's graphic with a specific color. | FlxSprite | ||
flicker(Duration:Number = 1):void
Tells this object to flicker, retro-style. | FlxObject | ||
followPath(Path:FlxPath, Speed:Number = 100, Mode:uint, AutoRotate:Boolean = false):void
Call this function to give this object a path to follow. | FlxObject | ||
Retrieve the midpoint of this object in world coordinates. | FlxObject | ||
Call this function to figure out the on-screen position of the object. | FlxObject | ||
hurt(Damage:Number):void
Reduces the "health" variable of this sprite by the amount specified in Damage. | FlxObject | ||
isTouching(Direction:uint):Boolean
Handy function for checking if this object is touching a particular surface. | FlxObject | ||
justTouched(Direction:uint):Boolean
Handy function for checking if this object is just landed on a particular surface. | FlxObject | ||
kill():void
Handy function for "killing" game objects. | FlxBasic | ||
loadGraphic(Graphic:Class, Animated:Boolean = false, Reverse:Boolean = false, Width:uint = 0, Height:uint = 0, Unique:Boolean = false):FlxSprite
Load an image from an embedded graphic file. | FlxSprite | ||
loadRotatedGraphic(Graphic:Class, Rotations:uint = 16, Frame:int = -1, AntiAliasing:Boolean = false, AutoBuffer:Boolean = false):FlxSprite
Create a pre-rotated sprite sheet from a simple sprite. | FlxSprite | ||
makeGraphic(Width:uint, Height:uint, Color:uint = 0xffffffff, Unique:Boolean = false, Key:String = null):FlxSprite
This function creates a flat colored square image dynamically. | FlxSprite | ||
[override]
Check and see if this object is currently on screen. | FlxSprite | ||
Checks to see if some FlxObject overlaps this FlxObject or FlxGroup. | FlxObject | ||
overlapsAt(X:Number, Y:Number, ObjectOrGroup:FlxBasic, InScreenSpace:Boolean = false, Camera:FlxCamera = null):Boolean
Checks to see if this FlxObject were located at the given position, would it overlap the FlxObject or FlxGroup?
This is distinct from overlapsPoint(), which just checks that point, rather than taking the object's size into account. | FlxObject | ||
Checks to see if a point in 2D world space overlaps this FlxObject object. | FlxObject | ||
Checks to see if a point in 2D world space overlaps this FlxSprite object's current displayed pixels. | FlxSprite | ||
play(AnimName:String, Force:Boolean = false):void
Plays an existing animation (e.g. | FlxSprite | ||
postUpdate():void [override]
Automatically called after update() by the game loop,
this function just calls updateAnimation(). | FlxSprite | ||
preUpdate():void [override]
Pre-update is called right before update() on each object in the game loop. | FlxObject | ||
randomFrame():void
Tell the sprite to change to a random frame of animation
Useful for instantiating particles or other weird things. | FlxSprite | ||
replaceColor(Color:uint, NewColor:uint, FetchPositions:Boolean = false):Array | FlxSprite | ||
reset(X:Number, Y:Number):void
Handy function for reviving game objects. | FlxObject | ||
revive():void
Handy function for bringing game objects "back to life". | FlxBasic | ||
[static]
The main collision resolution function in flixel. | FlxObject | ||
[static]
The X-axis component of the object separation process. | FlxObject | ||
[static]
The Y-axis component of the object separation process. | FlxObject | ||
setFormat(Font:String = null, Size:Number = 8, Color:uint = 0xffffff, Alignment:String = null, ShadowColor:uint = 0):FlxText
You can use this if you have a lot of text parameters
to set instead of the individual properties. | FlxText | ||
setOriginToCorner():void
Helper function that just sets origin to (0,0)
| FlxSprite | ||
This function draws or stamps one FlxSprite onto another. | FlxSprite | ||
stopFollowingPath(DestroyPath:Boolean = false):void
Tells this object to stop following the path its on. | FlxObject | ||
toString():String
Convert object to readable string name. | FlxBasic | ||
update():void
Override this function to update your class's position and appearance. | FlxBasic |
Method | Defined By | ||
---|---|---|---|
advancePath(Snap:Boolean = true):FlxPoint
Internal function that decides what node in the path to aim for next based on the behavior flags. | FlxObject | ||
calcFrame():void [override]
Internal function to update the current animation frame. | FlxText | ||
dtfCopy():TextFormat
A helper function for updating the TextField that we use for rendering. | FlxText | ||
resetHelpers():void
Resets some important variables for sprite optimization and rendering. | FlxSprite | ||
updateAnimation():void
Internal function for updating the sprite's animation. | FlxSprite | ||
updateMotion():void
Internal function for updating the position and speed of this object. | FlxObject | ||
updatePathMotion():void
Internal function for moving the object along the path. | FlxObject |
_regen | property |
protected var _regen:Boolean
Whether the actual text field needs to be regenerated and stamped again.
This is NOT the same thing as FlxSprite.dirty
.
_shadow | property |
protected var _shadow:uint
Internal tracker for the text shadow color, default is clear/transparent.
_textField | property |
protected var _textField:TextField
Internal reference to a Flash TextField
object.
alignment | property |
alignment:String
The alignment of the font ("left", "right", or "center").
public function get alignment():String
public function set alignment(value:String):void
color | property |
color:uint
[override] The color of the text being displayed.
public function get color():uint
public function set color(value:uint):void
font | property |
font:String
The font used for this text.
public function get font():String
public function set font(value:String):void
shadow | property |
shadow:uint
The color of the text shadow in 0xAARRGGBB hex format.
public function get shadow():uint
public function set shadow(value:uint):void
size | property |
size:Number
The size of the text being displayed.
public function get size():Number
public function set size(value:Number):void
text | property |
text:String
The text being displayed.
public function get text():String
public function set text(value:String):void
FlxText | () | Constructor |
public function FlxText(X:Number, Y:Number, Width:uint, Text:String = null, EmbeddedFont:Boolean = true)
Creates a new FlxText
object at the specified position.
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 is determined automatically).
| |
Text:String (default = null ) — The actual text you would like to display initially.
| |
EmbeddedFont:Boolean (default = true ) — Whether this text field uses embedded fonts or nto
|
calcFrame | () | method |
override protected function calcFrame():void
Internal function to update the current animation frame.
destroy | () | method |
override public function destroy():void
Clean up memory.
dtfCopy | () | method |
protected function dtfCopy():TextFormat
A helper function for updating the TextField
that we use for rendering.
TextFormat — A writable copy of TextField.defaultTextFormat .
|
setFormat | () | method |
public function setFormat(Font:String = null, Size:Number = 8, Color:uint = 0xffffff, Alignment:String = null, ShadowColor:uint = 0):FlxText
You can use this if you have a lot of text parameters to set instead of the individual properties.
Parameters
Font:String (default = null ) — The name of the font face for the text display.
| |
Size:Number (default = 8 ) — The size of the font (in pixels essentially).
| |
Color:uint (default = 0xffffff ) — The color of the text in traditional flash 0xRRGGBB format.
| |
Alignment:String (default = null ) — A string representing the desired alignment ("left,"right" or "center").
| |
ShadowColor:uint (default = 0 ) — A uint representing the desired text shadow color in flash 0xRRGGBB format.
|
FlxText — This FlxText instance (nice for chaining stuff together, if you're into that).
|