Packagenet.flashpunk.graphics
Classpublic class Spritemap
InheritanceSpritemap Inheritance Image Inheritance Graphic Inheritance Object
Subclasses TiledSpritemap

Performance-optimized animated Image. Can have multiple animations, which draw frames from the provided source image to the screen.



Public Properties
 PropertyDefined By
 Inheritedactive : Boolean = false
If the graphic should update.
Graphic
 Inheritedalpha : Number
Change the opacity of the Image, a value from 0 to 1.
Image
 Inheritedangle : Number = 0
Rotation of the image, in degrees.
Image
 Inheritedblend : String
Optional blend mode to use when drawing this image.
Image
  callback : Function
Optional callback function for animation end.
Spritemap
  clipRect : Rectangle
[override] [read-only] Clipping rectangle for the spritemap.
Spritemap
 Inheritedcolor : uint
The tinted color of the Image.
Image
  columns : uint
[read-only] Columns in the Spritemap.
Spritemap
  complete : Boolean = true
If the animation has stopped.
Spritemap
  currentAnim : String
[read-only] The currently playing animation.
Spritemap
 InheriteddrawMask : BitmapData
Set the transparency mask of the Image.
Image
 Inheritedflipped : Boolean
If you want to draw the Image horizontally flipped.
Image
  frame : int
Sets the current frame index.
Spritemap
  frameCount : uint
[read-only] The amount of frames in the Spritemap.
Spritemap
 Inheritedheight : uint
[read-only] Height of the image.
Image
  index : uint
Current index of the playing animation.
Spritemap
 Inheritedlocked : Boolean
[read-only] True if the image is locked.
Image
 InheritedoriginX : Number = 0
X origin of the image, determines transformation point.
Image
 InheritedoriginY : Number = 0
Y origin of the image, determines transformation point.
Image
  rate : Number = 1
Animation speed factor, alter this to speed up/slow down all animations.
Spritemap
 Inheritedrelative : Boolean = true
If the graphic should render at its position relative to its parent Entity's position.
Graphic
  rows : uint
[read-only] Rows in the Spritemap.
Spritemap
 Inheritedscale : Number = 1
Scale of the image, affects both x and y scale.
Image
 InheritedscaledHeight : Number
The scaled height of the image.
Image
 InheritedscaledWidth : Number
The scaled width of the image.
Image
 InheritedscaleX : Number = 1
X scale of the image.
Image
 InheritedscaleY : Number = 1
Y scale of the image.
Image
 InheritedscrollX : Number = 1
X scrollfactor, effects how much the camera offsets the drawn graphic.
Graphic
 InheritedscrollY : Number = 1
Y scrollfactor, effects how much the camera offsets the drawn graphic.
Graphic
 Inheritedsmooth : Boolean
If the image should be drawn transformed with pixel smoothing.
Image
 Inheritedtinting : Number
The amount the image will be tinted, suggested values from 0 to 1.
Image
 InheritedtintMode : Number
The tint mode - multiply or colorize.
Image
 Inheritedvisible : Boolean = true
If the graphic should render.
Graphic
 Inheritedwidth : uint
[read-only] Width of the image.
Image
 Inheritedx : Number = 0
X offset.
Graphic
 Inheritedy : Number = 0
Y offset.
Graphic
Protected Properties
 PropertyDefined By
 Inherited_alpha : Number = 1
Image
 Inheritedassign : Function
Graphic
 Inherited_class : String
Image
 Inherited_color : uint = 0x00FFFFFF
Image
 Inherited_colorTransform : ColorTransform
Image
 Inherited_drawMask : BitmapData
Image
 Inherited_flip : BitmapData
Image
 Inherited_flipped : Boolean
Image
 Inherited_flips : Object
[static]
Image
 Inherited_matrix : Matrix
Image
 Inheritedsource : BitmapData
[read-only]
Image
 Inherited_tint : ColorTransform
Image
 Inherited_tintFactor : Number = 1.0
Image
 Inherited_tintMode : Number = 0.0
Image
Public Methods
 MethodDefined By
  
Spritemap(source:*, frameWidth:uint = 0, frameHeight:uint = 0, callback:Function = null)
Constructor.
Spritemap
  
add(name:String, frames:Array, frameRate:Number = 0, loop:Boolean = true):Anim
Add an Animation.
Spritemap
 Inherited
centerOO():void
Centers the Image's originX/Y to its center.
Image
 Inherited
Centers the Image's originX/Y to its center.
Image
 Inherited
clear():void
Clears the image buffer.
Image
 Inherited
createCircle(radius:uint, color:uint = 0xFFFFFF, alpha:Number = 1):Image
[static] Creates a new circle Image.
Image
 Inherited
createGradient(width:uint, height:uint, fromX:Number, fromY:Number, toX:Number, toY:Number, fromColor:uint, toColor:uint, fromAlpha:Number = 1, toAlpha:Number = 1):Image
[static] Creates a new gradient Image.
Image
 Inherited
createRect(width:uint, height:uint, color:uint = 0xFFFFFF, alpha:Number = 1):Image
[static] Creates a new rectangle Image.
Image
  
getFrame(column:uint = 0, row:uint = 0):uint
Gets the frame index based on the column and row of the source image.
Spritemap
 Inherited
lock():void
Lock the image, preventing updateBuffer() from being run until unlock() is called, for performance.
Image
  
play(name:String, reset:Boolean = false, frame:int = 0):Anim
Plays an animation.
Spritemap
  
randFrame():void
Assigns the Spritemap to a random frame.
Spritemap
 Inherited
render(target:BitmapData, point:Point, camera:Point):void
Renders the graphic to the screen buffer.
Graphic
  
setAnimFrame(name:String, index:int):void
Sets the frame to the frame index of an animation.
Spritemap
  
setFrame(column:uint = 0, row:uint = 0):void
Sets the current display frame based on the column and row of the source image.
Spritemap
 Inherited
unlock():void
Unlock the image.
Image
 Inherited
update():void
Updates the graphic.
Graphic
  
updateBuffer(clearBefore:Boolean = false):void
[override] Updates the spritemap's buffer.
Spritemap
Protected Methods
 MethodDefined By
 Inherited
Updates the color transform
Image
Public Constants
 ConstantDefined By
 InheritedTINTING_COLORIZE : Number = 1.0
[static] tintMode value to tint in colorize mode.
Image
 InheritedTINTING_MULTIPLY : Number = 0.0
[static] tintMode value to tint in multiply mode.
Image
Property Detail
callbackproperty
public var callback:Function

Optional callback function for animation end.

clipRectproperty 
clipRect:Rectangle  [read-only] [override]

Clipping rectangle for the spritemap.


Implementation
    public function get clipRect():Rectangle
columnsproperty 
columns:uint  [read-only]

Columns in the Spritemap.


Implementation
    public function get columns():uint
completeproperty 
public var complete:Boolean = true

If the animation has stopped.

currentAnimproperty 
currentAnim:String  [read-only]

The currently playing animation.


Implementation
    public function get currentAnim():String
frameproperty 
frame:int

Sets the current frame index. When you set this, any animations playing will be stopped to force the frame.


Implementation
    public function get frame():int
    public function set frame(value:int):void
frameCountproperty 
frameCount:uint  [read-only]

The amount of frames in the Spritemap.


Implementation
    public function get frameCount():uint
indexproperty 
index:uint

Current index of the playing animation.


Implementation
    public function get index():uint
    public function set index(value:uint):void
rateproperty 
public var rate:Number = 1

Animation speed factor, alter this to speed up/slow down all animations.

rowsproperty 
rows:uint  [read-only]

Rows in the Spritemap.


Implementation
    public function get rows():uint
Constructor Detail
Spritemap()Constructor
public function Spritemap(source:*, frameWidth:uint = 0, frameHeight:uint = 0, callback:Function = null)

Constructor.

Parameters
source:* — Source image.
 
frameWidth:uint (default = 0) — Frame width.
 
frameHeight:uint (default = 0) — Frame height.
 
callback:Function (default = null) — Optional callback function for animation end.
Method Detail
add()method
public function add(name:String, frames:Array, frameRate:Number = 0, loop:Boolean = true):Anim

Add an Animation.

Parameters

name:String — Name of the animation.
 
frames:Array — Array of frame indices to animate through.
 
frameRate:Number (default = 0) — Animation speed (with variable framerate: in frames per second, with fixed framerate: in frames per frame).
 
loop:Boolean (default = true) — If the animation should loop.

Returns
Anim — A new Anim object for the animation.
getFrame()method 
public function getFrame(column:uint = 0, row:uint = 0):uint

Gets the frame index based on the column and row of the source image.

Parameters

column:uint (default = 0) — Frame column.
 
row:uint (default = 0) — Frame row.

Returns
uint — Frame index.
play()method 
public function play(name:String, reset:Boolean = false, frame:int = 0):Anim

Plays an animation.

Parameters

name:String — Name of the animation to play.
 
reset:Boolean (default = false) — If the animation should force-restart if it is already playing.
 
frame:int (default = 0) — Frame of the animation to start from, if restarted.

Returns
Anim — Anim object representing the played animation.
randFrame()method 
public function randFrame():void

Assigns the Spritemap to a random frame.

setAnimFrame()method 
public function setAnimFrame(name:String, index:int):void

Sets the frame to the frame index of an animation.

Parameters

name:String — Animation to draw the frame frame.
 
index:int — Index of the frame of the animation to set to.

setFrame()method 
public function setFrame(column:uint = 0, row:uint = 0):void

Sets the current display frame based on the column and row of the source image. When you set the frame, any animations playing will be stopped to force the frame.

Parameters

column:uint (default = 0) — Frame column.
 
row:uint (default = 0) — Frame row.

updateBuffer()method 
override public function updateBuffer(clearBefore:Boolean = false):void

Updates the spritemap's buffer.

Parameters

clearBefore:Boolean (default = false)