Naev

Module camera

Lua bindings to interact with the Camera.

An example would be:

 

Functions

set (target[, hard_over=false[, speed=math.min(2000]]) Sets the camera.
get () Gets the x/y position and zoom of the camera.
get () Gets the camera position.
setZoom (zoom[, hard_over=false[, speed=naev.conf().zoom_speed]]) Sets the camera zoom.
get () Gets the camera zoom.
shake (amplitude) Makes the camera shake.


Functions

set (target[, hard_over=false[, speed=math.min(2000]])
Sets the camera.

Make sure to reset camera after using it or we'll run into trouble.

Parameters:

  • target Pilot, Vec2 or nil It will follow pilots around. If nil, it follows the player.
  • hard_over boolean Indicates that the camera should instantly teleport instead of fly over. (default false)
  • speed Speed at which to fly over if hard_over is false. (default math.min(2000)

Usage:

  • camera.set() -- Resets the camera to the pilot hard.
    
  • camera.set( a_pilot, true ) -- Flies camera over to a_pilot.
    
  • camera.set( vec2.new() ) -- Jumps camera to 0,0
    
get ()
Gets the x/y position and zoom of the camera.

Returns:

  1. number X position of the camera.
  2. number Y position of the camera.
  3. number Zoom level of the camera.
get ()
Gets the camera position.

Returns:

    Vec2 Position of the camera.
setZoom (zoom[, hard_over=false[, speed=naev.conf().zoom_speed]])
Sets the camera zoom.

Make sure to reset camera the zoom after using it or we'll run into trouble.

Parameters:

  • zoom number Level of zoom to use (1 would indicate 1 unit = 1 pixel while 2 would be 1 unit = 2 pixels)
  • hard_over boolean Indicates that the camera should change the zoom gradually instead of instantly. (default false)
  • speed number Rate of change to use. (default naev.conf().zoom_speed)

Usage:

    camera.setZoom() -- Resets the camera zoom
    
get ()
Gets the camera zoom.

Returns:

  1. number Zoom level of the camera.
  2. number Maximum zoom level of the camera (furthest).
  3. number Minimum zoom level of the camera (closest).
shake (amplitude)
Makes the camera shake.

Parameters:

  • amplitude number Amplitude of the shaking.

Usage:

  • camera.shake() -- Shakes the camera with amplitude 1.
    
  • camera.shake( 0.5 ) -- Shakes the camera with amplitude .5
    
generated by LDoc 1.5.0 Last updated 2024-12-13 16:37:51