Camera (class)
Jump to navigation
Jump to search
This class provides access to the SMBX cameras. NOTE: Only access this class in onCameraUpdate if you want the correct values or overwrite these values!
Static functions
| Static Camera Functions (Overworld and level) | ||
|---|---|---|
| Function | Return values | Description |
| Camera.get() | table of Camera | Returns all Cameras |
Instance functions
These fields and functions are part of Camera Objects and have to be called for that object. Trying to call them from the static Camera class will result in an error. Example (feel free to copy it into your lua file to see how it works):
local player1Camera = Camera.get()[1]
function onCameraUpdate()
player1Camera.x = player1Camera.x + 200
end
| Camera class | |||
|---|---|---|---|
| Type | Function/Field | Return values/Value type | Description |
| Field | Camera.x | number | The x position of the camera at the scene. |
| Field | Camera.y | number | The y position of the camera at the scene. |
| Field | Camera.renderX | number | The x position of the camera at the screen. (LunaLua ≥ v0.7.3) |
| Field | Camera.renderY | number | The y position of the camera at the screen. (LunaLua ≥ v0.7.3) |
| Field | Camera.width | number | The width of the camera. |
| Field | Camera.height | number | The height of the camera. |
| Camera Memory | |||
|---|---|---|---|
| Name | Memory address | Memory type | Description |
| Render X Position | CAM+0x00 | FIELD_DFLOAT | The x position of the camera at the screen. |
| Render Y Position | CAM+0x08 | FIELD_DFLOAT | The y position of the camera at the screen. |
| Width | CAM+0x10 | FIELD_DFLOAT | The width of the camera. |
| Height | CAM+0x18 | FIELD_DFLOAT | The height of the camera. |
| Is Split Screen? | CAM+0x20 | FIELD_BOOL | Only the second camera will return true when the camera is split. |
| Unknown | CAM+0x22 | Unknown | Unknown. |
| Unknown | CAM+0x24 | Unknown | Unknown. |
| Unknown | CAM+0x26 | Unknown | Unknown. |
| Unknown | CAM+0x28 | Unknown | Unknown. |
| Unknown | CAM+0x2A | Unknown | Unknown. |
| Player's Y Difference | CAM+0x2C | FIELD_DFLOAT | The player's Y position difference. This will only work when the cameras are splitted vertically, otherwise it returns 0. The number will cap at 150 or -150. |
| Unknown Timer | CAM+0x34 | FIELD_DWORD | Starts at 200 which then decreases to 0. The reason it decreases seems related to the cameras being in different sections? |