Packagecom.pblabs.rendering2D.spritesheet
Classpublic class SpriteSheetComponent
InheritanceSpriteSheetComponent Inheritance SpriteContainerComponent Inheritance EntityComponent Inheritance Object

Handles loading and retrieving data about a sprite sheet to use for rendering.

Functionality exists to allow several directions to be specified per frame. This enables you to, for instance, visually rotate a sprite without rotating the actual object it belongs to.

Because we may group them in different ways, we distinguish between "raw frames" and a "frame" which might be made up of multiple directions.

On the subject of sprite sheet order: the divider may alter this, but in general, frames are numbered left to right, top to bottom. If you have a 4 direction sprite sheet, then 0,1,2,3 will be frame 1, 4,5,6,7 will be 2, and so on.

Be aware that Flash implements an upper limit on image size - going over 2048 pixels in any dimension will lead to problems.



Public Properties
 PropertyDefined By
 Inheritedcenter : Point
Specifies an offset so the sprite is centered correctly.
SpriteContainerComponent
 Inheritedcentered : Boolean
[read-only] Indicates that the spriteSheet has a centered alignment.
SpriteContainerComponent
 InheriteddegreesPerDirection : Number
[read-only] The number of degrees separating each direction.
SpriteContainerComponent
 InheriteddirectionsPerFrame : Number = 1
The number of directions per frame.
SpriteContainerComponent
  divider : ISpriteSheetDivider
The divider to use to chop up the sprite sheet into frames.
SpriteSheetComponent
  failed : Boolean
[read-only] Indicates if the ImageResource has failed loading
SpriteSheetComponent
 InheritedframeCount : int
The number of frames the sprite container has.
SpriteContainerComponent
  image : ImageResource
The image resource to use for this sprite sheet.
SpriteSheetComponent
  imageData : BitmapData
[read-only] The bitmap data of the loaded image.
SpriteSheetComponent
  imageFilename : String
The filename of the image to use for this sprite sheet.
SpriteSheetComponent
  isLoaded : Boolean
[override] [read-only] True if the image data associated with this sprite sheet has been loaded.
SpriteSheetComponent
 InheritedisRegistered : Boolean
[read-only] Whether or not the component is currently registered with an entity.
EntityComponent
  loaded : Boolean
[read-only] Indicates if the ImageResource has been loaded
SpriteSheetComponent
  loading : Boolean
[read-only] Indicates if the ImageResource loading is in progress
SpriteSheetComponent
 Inheritedmodifiers : Array
Array with BitmapData modifiers that will be pre-rendered
SpriteContainerComponent
 Inheritedname : String
[read-only] The name given to the component when it is added to an entity.
EntityComponent
 Inheritedowner : IEntity
A reference to the entity that this component currently belongs to.
EntityComponent
 InheritedrawFrameCount : int
[read-only] The total number of frames the sprite container has.
SpriteContainerComponent
Protected Properties
 PropertyDefined By
 Inheritedframes : Array = null
SpriteContainerComponent
Public Methods
 MethodDefined By
 Inherited
getFrame(index:int, direction:Number = 0.0):BitmapData
Gets the bitmap data for a frame at the specified index.
SpriteContainerComponent
  
initializeFromBitmapDataArray(bitmaps:Array):void
From an array of BitmapDatas, initialize the sprite sheet, ignoring divider + filename.
SpriteSheetComponent
 Inherited
register(owner:IEntity, name:String):void
Registers the component with an entity.
EntityComponent
 Inherited
reset():void
This is called by an entity on all of its components any time a component is added or removed.
EntityComponent
 Inherited
unregister():void
Unregisters the component from an entity.
EntityComponent
Protected Methods
 MethodDefined By
 Inherited
SpriteContainerComponent
 Inherited
Deletes the frames so this class can be re-used with a new set of frames.
SpriteContainerComponent
 Inherited
getRawFrame(index:int):BitmapData
Gets the frame at the specified index.
SpriteContainerComponent
  
[override]
SpriteSheetComponent
  
onAdd():void
[override]
SpriteSheetComponent
  
SpriteSheetComponent
  
SpriteSheetComponent
  
onRemove():void
[override]
SpriteSheetComponent
 Inherited
onReset():void
This is called anytime a component is added or removed from the owner entity.
EntityComponent
Property Detail
dividerproperty
divider:ISpriteSheetDivider

The divider to use to chop up the sprite sheet into frames. If the divider isn't set, the image will be treated as one whole frame.


Implementation
    public function get divider():ISpriteSheetDivider
    public function set divider(value:ISpriteSheetDivider):void
failedproperty 
failed:Boolean  [read-only]

Indicates if the ImageResource has failed loading


Implementation
    public function get failed():Boolean
imageproperty 
image:ImageResource

The image resource to use for this sprite sheet.


Implementation
    public function get image():ImageResource
    public function set image(value:ImageResource):void
imageDataproperty 
imageData:BitmapData  [read-only]

The bitmap data of the loaded image.


Implementation
    public function get imageData():BitmapData
imageFilenameproperty 
imageFilename:String

The filename of the image to use for this sprite sheet.


Implementation
    public function get imageFilename():String
    public function set imageFilename(value:String):void
isLoadedproperty 
isLoaded:Boolean  [read-only] [override]

True if the image data associated with this sprite sheet has been loaded.


Implementation
    public function get isLoaded():Boolean
loadedproperty 
loaded:Boolean  [read-only]

Indicates if the ImageResource has been loaded


Implementation
    public function get loaded():Boolean
loadingproperty 
loading:Boolean  [read-only]

Indicates if the ImageResource loading is in progress


Implementation
    public function get loading():Boolean
Method Detail
getSourceFrames()method
override protected function getSourceFrames():Array

Returns
Array
initializeFromBitmapDataArray()method 
public function initializeFromBitmapDataArray(bitmaps:Array):void

From an array of BitmapDatas, initialize the sprite sheet, ignoring divider + filename.

Parameters

bitmaps:Array

onAdd()method 
override protected function onAdd():void

onImageFailed()method 
protected function onImageFailed(resource:ImageResource):void

Parameters

resource:ImageResource

onImageLoaded()method 
protected function onImageLoaded(resource:ImageResource):void

Parameters

resource:ImageResource

onRemove()method 
override protected function onRemove():void