Content:
- Methods

Creates a sprite object based on an image file containing a sprite or a spritesheet.

spr = gfx.CreateSprite( file, group, callback ) → game object: CreateSprite

To create a new Sprite just pass the image name as first parameter:

gfx.CreateSprite( "/Sys/Img/Bunny.png", "bunnies" );

Spritesheets can be loaded in two ways:

The simple one is a specific file pattern
“Img/Sheetname_WIDTHxHEIGHTxSPRITE_SXxSPRITE_SY or
“Img/Sheetname_stripTOTAL_WIDTHxHEIGHTxSPRITE_SXxSPRITE_SY
if you have a different amount of sprites than the rectangle of spritesx * spritesy sprites.

Example from the downloadable demo Grannies and Zombies:

granny = gfx.CreateSprite( "Img/Granny_1600x1000x8x5", "granny" );
zombie = gfx.CreateSprite( "Img/Zombie_strip35_1400x1000x7x5", "zombie" );

The second way is to create a SpriteSheet using the CreateSpriteSheet method which might come handy if a single sprite has multiple animations or if a sprite is reused but using a different sprite sheet.

Methods

The following methods are available on the Sprite object:

addedBoolean
alphaNumber: fraction (0..1)
angleNumber: fraction (0..1)
aspectNumber
Contains( x, y ) → Boolean
dataObject
GetFrame() → Number: integer
Goto( frame )
groupString
heightNumber: fraction (0..1)
pivotXNumber: fraction (0..1)
pivotYNumber: fraction (0..1)
scaleXNumber: factor
scaleYNumber: factor
SetSize( w, h )
Stop()
Update()
visibleBoolean
widthNumber
xNumber
yNumber: fraction (0..1)