getSpriteOrigin()
Purpose
Find the origin point of a sprite
Description
Find the origin point of the specified sprite. Default is the centre (0, 0)
Syntax
origin = getSpriteOrigin( sprite )
Arguments
sprite handle of the sprite
origin origin point of the sprite { x , y }
Example
image = loadImage( "Untied Games/Enemy A", false )
enemy = createSprite()
setSpriteImage( enemy, image )
setSpriteAnimation( enemy, 0, 4, 20 )
setSpriteLocation( enemy, { 0, 0 } )
size = getSpriteSize( enemy )
setSpriteScale( enemy, { 8, 8 } )
loop
clear()
origin = getSpriteOrigin( enemy )
printAt( 20, 10, "Sprite origin x = ", origin.x, " y = ", origin.y )
printAt( 20, 11, "Press A to move origin to the top left" )
printAt( 20, 12, "Press B to move origin to the centre" )
c = controls( 0 )
if c.a then
setSpriteOrigin( enemy, { -size.x / 2, -size.y / 2 } )
endIf
if c.b then
setSpriteOrigin( enemy, { 0, 0 } )
endIf
updateSprites()
drawSprites()
update()
repeat
Associated Commands