| Package | PBLabs.Rendering2D |
| Class | public class SpriteSheetComponent |
| Inheritance | SpriteSheetComponent EntityComponent |
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.
| Property | Defined by | ||
|---|---|---|---|
| Center : Point
Specifies an offset so the sprite is centered correctly.
| SpriteSheetComponent | ||
| DegreesPerDirection : Number [read-only]
The number of degrees separating each direction.
| SpriteSheetComponent | ||
| DirectionsPerFrame : Number = 1
The number of directions per frame.
| SpriteSheetComponent | ||
| Divider : ISpriteSheetDivider
The divider to use to chop up the sprite sheet into frames.
| SpriteSheetComponent | ||
| FrameCount : int [read-only]
The number of frames the sprite sheet has.
| SpriteSheetComponent | ||
| 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 [read-only]
True if the image data associated with this sprite sheet has been loaded.
| SpriteSheetComponent | ||
![]() | IsRegistered : Boolean
Whether or not the component is currently registered with an entity.
| EntityComponent | |
![]() | Name : String
The name given to the component when it is added to an entity.
| EntityComponent | |
![]() | Owner : IEntity
A reference to the entity that this component currently belongs to.
| EntityComponent | |
| RawFrameCount : int [read-only]
The total number of frames the sprite sheet has.
| SpriteSheetComponent | ||
| Method | Defined by | ||
|---|---|---|---|
|
GetFrame(index:int, direction:Number = 0.0):BitmapData
Gets the bitmap data for a frame at the specified index.
| SpriteSheetComponent | ||
![]() |
Registers the component with an entity.
| EntityComponent | |
![]() |
Reset():void
This is called by an entity on all of its components any time a component
is added or removed.
| EntityComponent | |
![]() |
Unregister():void
Unregisters the component from an entity.
| EntityComponent | |
| Method | Defined by | ||
|---|---|---|---|
|
_BuildFrames():void
| SpriteSheetComponent | ||
|
_GetRawFrame(index:int):BitmapData
Gets the frame at the specified index.
| SpriteSheetComponent | ||
![]() |
_OnAdd():void
This is called when the component is added to an entity.
| EntityComponent | |
|
_OnImageFailed(resource:ImageResource):void
| SpriteSheetComponent | ||
|
_OnImageLoaded(resource:ImageResource):void
| SpriteSheetComponent | ||
![]() |
_OnRemove():void
This is called when the component is removed from an entity.
| EntityComponent | |
![]() |
_OnReset():void
This is called anytime a component is added or removed from the owner entity.
| EntityComponent | |
| Center | property |
Center:Point [read-write]Specifies an offset so the sprite is centered correctly. If it is not set, the sprite is centered.
Implementation public function get Center():Point
public function set Center(value:Point):void
| DegreesPerDirection | property |
DegreesPerDirection:Number [read-only]The number of degrees separating each direction.
Implementation public function get DegreesPerDirection():Number
| DirectionsPerFrame | property |
public var DirectionsPerFrame:Number = 1The number of directions per frame.
| Divider | property |
Divider:ISpriteSheetDivider [read-write]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
| FrameCount | property |
FrameCount:int [read-only]The number of frames the sprite sheet has. This counts each set of directions as one frame.
Implementation public function get FrameCount():int
| Image | property |
Image:ImageResource [read-write]The image resource to use for this sprite sheet.
Implementation public function get Image():ImageResource
public function set Image(value:ImageResource):void
| ImageData | property |
ImageData:BitmapData [read-only]The bitmap data of the loaded image.
Implementation public function get ImageData():BitmapData
| ImageFilename | property |
ImageFilename:String [read-write]The filename of the image to use for this sprite sheet.
Implementation public function get ImageFilename():String
public function set ImageFilename(value:String):void
| IsLoaded | property |
IsLoaded:Boolean [read-only]True if the image data associated with this sprite sheet has been loaded.
Implementation public function get IsLoaded():Boolean
| RawFrameCount | property |
RawFrameCount:int [read-only]The total number of frames the sprite sheet has. This counts each direction separately.
Implementation public function get RawFrameCount():int
| _BuildFrames | () | method |
protected function _BuildFrames():void
| _GetRawFrame | () | method |
protected function _GetRawFrame(index:int):BitmapDataGets the frame at the specified index. This does not take direction into account.
Parametersindex:int |
BitmapData |
| _OnImageFailed | () | method |
| _OnImageLoaded | () | method |
| GetFrame | () | method |
public function GetFrame(index:int, direction:Number = 0.0):BitmapDataGets the bitmap data for a frame at the specified index.
Parametersindex:int — The index of the frame to retrieve.
|
|
direction:Number (default = 0.0) — The direction of the frame to retrieve in degrees. This
can be ignored if there is only 1 direction per frame.
|
BitmapData — The bitmap data for the specified frame, or null if it doesn't exist.
|