setSpriteCamera()
Purpose
Move the sprite camera position
Description
Move the camera position for all sprites. The initial position is (0, 0, 1)
Syntax
setSpriteCamera( pos )
setSpriteCamera( xpos, ypos )
setSpriteCamera( xpos, ypos, zpos )
Arguments
pos position vector of the camera { x, y, z }
xpos position of the camera in the x axis (pan left/right)
ypos position of the camera in the y axis (pan up/down)
zpos position of the camera in the z axis (zoom in/out)
Example
image = loadImage( "Untied Games/Enemy A", false )
enemy = []
for i = 0 to 4 loop
enemy[i] = createSprite()
setSpriteImage( enemy[i], image )
setSpriteAnimation( enemy[i], 0, 4, 20 )
setSpriteLocation( enemy[i], { ( i % 2 ) * 400 + 400, int( i / 2 ) * 300 + 200 } )
setSpriteScale( enemy[i], { 4, 4 } )
repeat
camera = getSpriteCamera()
rotation = getSpriteCameraRotation()
loop
clear()
c = controls( 0 )
printAt( 0, 0, "Camera position: x = ", camera.x, " y = ", camera.y, " z = ", camera.z, " rotation: ", rotation )
printAt( 0, 1, "Use left joypad to pan, right joypad to zoom/rotate" )
if c.up then
camera.y -= 5
endIf
if c.down then
camera.y += 5
endIf
if c.left then
camera.x -= 5
endIf
if c.right then
camera.x += 5
endIf
if c.x then
camera.z += 0.05
endIf
if c.b then
camera.z -= 0.05
endIf
if c.y then
rotation -= 0.5
endIf
if c.a then
rotation += 0.5
endIf
setSpriteCamera( camera.x, camera.y, camera.z )
setSpriteCameraRotation( rotation )
updateSprites()
drawSprites()
update()
repeat
Associated Commands
centreSpriteCamera(), getSpriteCamera(), getSpriteCameraRotation(), setSpriteCameraRotation()