getSpriteLocation()
Purpose
Get the position of a sprite on the screen
Description
Get the horizontal and vertical position of a sprite
Syntax
position = getSpriteLocation( sprite )
xpos = sprite.x; ypos = sprite.y
Arguments
sprite The handle of the created sprite
position A vetor conatining the x and y coordinates of the sprtite { x, y }
xpos The horizontal position on the screen in pixels
ypos The vertical position on the screen in pixels
Example
radians( true )
image = loadImage( "Untied Games/Enemy small top C", false )
ship = createSprite()
setSpriteImage( ship, image )
lastpos = { gWidth() / 2, gHeight() / 2 }
setSpriteLocation( ship, lastpos )
setSpriteScale( ship, { 4, 4 } )
loop
clear()
c = controls( 0 )
printAt( 0, 0, "Use left joystick to control sprite" )
setSpriteSpeed( ship, { 480 * c.lx, -480 * c.ly } )
curpos = getSpriteLocation( ship )
if curpos != lastpos then
setSpriteRotation(ship, -pi / 2 + atan2( curpos.y - lastpos.y, curpos.x - lastpos.x ) )
lastpos = curpos
endIf
updateSprites()
drawSprites()
update()
repeat
Associated Commands