Creates a sprite object based on an image file containing a sprite or a spritesheet.
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
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.
The following methods are available on the Sprite object:
String: path to file ( “/absolute/...” or “relative/...” )
Indicates if the sprite has been added to the game
The objects alpha value
The rotation fraction of the object
The aspect ratio of the sprite
Checks if a point is contained in the sprite
An object for saving individual extra properties.
Flips the sprite on the horizontal and/or the vertical axis.
Returns the current frame
Displays a specific frame of an animation
The objects group identifier
The height of the object
The x pivot for rotations
The y pivot for rotations
Start playing the sprite animation
Start playing the sprite animation in a given frame range
Play the animation until a specific frame is reached
The horizontal scaling
The vertical scaling
Define if the animation should loop or stop at the end
Set the individual 2d transformation
Define at which speed the animation will play. 1 equals to 60 fps
Define the frame range the animation should show.
Set the sprite size on the screen
Change the animation to another.
Change the sprite texture to another.
Sets up tween methods and properties without playing it.
Start tweening automatically on every rendered frame.
Updates a tween to the current time (if not paused).
Stop playin the animation.
Causes the animation to stop playing at a specific frame
Performs an animation on the control.
The target object is for the position, size and rotation that the control has at the end of the animation.
The type specifies the behavior and the speed of the animation. Separated by a dot, you must also specify whether you want to apply this behavior to the beginning (In), end (Out), or to both (InOut) times of the animation.
With the amount of repeats you can control how many times you want to play the animation.
If you have jojo activated, the animation will alternate between forward and backward playback, so that if the repetition value is odd, the control will be at the start position again at the end of the animation.
Finally the callback function will be called after the animation has finished. Well, it's about time!
Updates internal properties
Indicates the objects visibility state
The obects width
X-position on the screen.
Y-position on the screen.