setSpriteAnimation()
Purpose
Animate a sprite
Description
Create a sprite from a tile sheet and animate it.
Syntax
setSpriteAnimation( sprite, startTile, endTile )
setSpriteAnimation( sprite, startTile, endTile, speed )
Arguments
sprite The handle of the sprite
startTile The number of the first tile in the animation sequence (0 based)
endTile The number of the last tile in the animation sequence (0 based)
speed The speed of the animation (default is 10)
Example
image = loadImage( "Untied Games/Enemy A", false )
enemy = createSprite()
setSpriteImage( enemy, image )
setSpriteAnimation( enemy, 0, 4, 20 )
lastpos = { gWidth() / 2, gHeight() / 2 }
setSpriteLocation( enemy, lastpos )
setSpriteScale( enemy, { 8, 8 } )
loop
clear()
updateSprites()
drawSprites()
update()
repeat
Associated Commands
getSpriteAnimFrame(), getSpriteAnimFrameCount(), getSpriteAnimSpeed(), setSpriteAnimFrame(), setSpriteAnimSpeed()