getSpriteVisibility()
Purpose
Find out if a sprite is visible
Description
Get the current visibility state of the specified sprite
Syntax
shown = getSpriteVisibility( sprite )
shown = sprite.visible
Arguments
sprite handle of the sprite
shown if the sprite is currently visible
Example
image = loadImage( "Untied Games/Enemy A", false )
enemy = createSprite()
setSpriteImage( enemy, image )
speed = 20
setSpriteAnimation( enemy, 0, 4, speed )
lastpos = { gWidth() / 2, gHeight() / 2 }
setSpriteLocation( enemy, lastpos )
setSpriteScale( enemy, { 8, 8 } )
loop
clear()
c = controls( 0 )
printAt( 0, 0, "Hold down the A button to show the sprite" )
setSpriteVisibility( enemy, c.a )
visible = getSpriteVisibility( enemy )
if visible then
printAt( 0, 1, "Sprite is visible" )
else
printAt( 0, 1, "Sprite is invisible" )
endIf
updateSprites()
drawSprites()
update()
repeat
Associated Commands