-
Notifications
You must be signed in to change notification settings - Fork 2
Camera
Cameras contain the all the data needed for the shader to render planes. And also helps to render sprites much easier.
They are returned by PM.newCamera()
Here are all the functions that come with the camera object.
Camera:setRotation(r)Sets the rotation (radians) of the camera.
Camera:setPosition(x,y)Changes the location of the camera to the specified world position.
Camera:setZoom(zoom)Changes how many world pixels wide the camera renders at.
Camera:setFov(fov)Changes the fov of the camera. (e.g. 2.0 makes objects seem twice as far, 0.5 only half as far)
Camera:setOffset(offset)Changes where the center of the camera renders. (0.5 is in the middle of the screen.)
r = Camera:getRotation()Gets the rotation (in radians) of the camera.
x,y = Camera:getPosition()Gets the world position of the camera.
x = Camera:getX()Like Camera.getPosition() but only for the x coordinate.
x = Camera:getY()Like Camera.getPosition() but only for the y coordinate.
zoom = Camera:getZoom()Gets the camera zoom.
fov = Camera:getFov()Gets the camera fov.
offset = Camera:getOffset()Gets the camera offset.
###Internal Variables
Here is a layout of the internal variables if you want greater control or ease of access!
| Type | Argument | Description |
|---|---|---|
| number | sw | The screen width of the camera. |
| number | sh | the screen height of the camera. |
| number | x | The x position of the camera (in world pixels) |
| number | y | The y position of the camera (in world pixels) |
| number | r | The r position of the camera. Changing this does not actually affect rotation. |
| number | z | The zoom of the camera. |
| number | f | The fov of the camera. |
| number | o | The offset of the camera. |
| number | x1 | Part of the 2x2 rotation matrix, this is the first indice. |
| number | y1 | Part of the 2x2 rotation matrix, this is the second indice. |
| number | x2 | Part of the 2x2 rotation matrix, this is the third indice. |
| number | y2 | Part of the 2x2 rotation matrix, this is the fourth indice. |
| table | buffer | Holds the buffer for sprites. |
| Canvas | rendercanvas | The canvas used to render the shader. |
| Canvas | canvas | Where the shader is rendered to, this is what gets drawn. (Deprecated.) |