Class Index | File Index

Classes


Class SpriteSheetUtils

The SpriteSheetUtils class is a collection of static methods for working with sprite sheets. A sprite sheet is a series of images (usually animation frames) combined into a single image on a regular grid. For example, an animation consisting of 8 100x100 images could be combined into a 400x200 sprite sheet (4 frames across by 2 high).
Defined in: SpriteSheetUtils.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
The SpriteSheetUtils class uses a static interface and should not be instantiated.
Method Summary
Method Attributes Method Name and Description
<static>  
SpriteSheetUtils.extractFrame(spriteSheet, frame)
Returns a single frame of the specified sprite sheet as a new PNG image.
<static>  
SpriteSheetUtils.flip(spriteSheet, flipData)
Builds a new extended sprite sheet based on the specified sprite sheet by adding flipped frames (vertical, horizontal, or both).
<static>  
SpriteSheetUtils.frameDataToString(frameData)
Returns a string representing the specified frameData object.
Class Detail
SpriteSheetUtils()
The SpriteSheetUtils class uses a static interface and should not be instantiated.
Method Detail
<static> SpriteSheetUtils.extractFrame(spriteSheet, frame)
Returns a single frame of the specified sprite sheet as a new PNG image.
Parameters:
spriteSheet
The SpriteSheet instance to extract a frame from.
frame
The frame number or sequence name to extract. If a sequence name is specified, only the first frame of the sequence will be extracted.

<static> SpriteSheetUtils.flip(spriteSheet, flipData)
Builds a new extended sprite sheet based on the specified sprite sheet by adding flipped frames (vertical, horizontal, or both). Flipping elements on the display list by using setting scaleX/scaleY to -1 is quite expensive in most browsers, so this method allows you to incur the cost of flipping once, in advance, without increasing the load size of your sprite sheets. Returns a new SpriteSheet instance containing the generated image and frame data.
Parameters:
spriteSheet
The sprite sheet to use as the source.
flipData
A generic object that specifies which frames will be flipped, what to name the flipped result, and how to flip the frames (horizontally, vertically, or both). Each property name indicates the name of a new sequence to create, and should reference an array where the first index is the name of the original sequence to flip, the second index indicates whether to flip it horizontally, the third index indicates whether to flip it vertically, and the fourth indicates what the "next" value for the resulting frame data should be. For example, the following would create a new sequence named "walk_left" consisting of the frames from the original "walk_right" sequence flipped horizontally: {walk_left:["walk_right", true, false]}

<static> SpriteSheetUtils.frameDataToString(frameData)
Returns a string representing the specified frameData object.
Parameters:
frameData
The frame data to output.

Documentation generated by JsDoc Toolkit 2.3.2 on Sun Feb 13 2011 22:46:01 GMT-0700 (MST)