setSpriteImage()
Purpose
Change the image associated with a sprite
Description
Set the sprites image to the one specified
Syntax
setSpriteImage( sprite, image )
sprite.image = image
Arguments
sprite handle of the sprite
image handle of the image
Example
image = []
image[1] = loadImage( "Untied Games/Enemy A", false )
image[2] = loadImage( "Untied Games/Enemy B", false )
enemy = createSprite()
setSpriteImage( enemy, image[1] )
setSpriteAnimation( enemy, 0, 4, 20 )
lastpos = { gWidth() / 2, gHeight() / 2 }
setSpriteLocation( enemy, lastpos )
setSpriteScale( enemy, { 8, 8 } )
current = 1
last = 1
loop
clear()
c = controls( 0 )
printAt( 0, 0, "Press A for image 1 and B for image 2" )
if c.a then
current = 1
endIf
if c.b then
current = 2
endIf
if current != last then
setSpriteImage( enemy, image[current] )
setSpriteAnimation( enemy, 0, 4, 20 )
last = current
endIf
updateSprites()
drawSprites()
update()
repeat
Associated Commands
createSprite(), getSpriteImage(), getSpriteImageSize(), setSpriteText()