Camera
Camera Guides
Functions
Camera Position
Returns the position of the camera in game coordinates. This will be the coordinate of the upper left corner of the screen.
Return Type - Point 2d
Signatures
Camera X
Returns the x location of the camera in game coordinates. This represents the left most x value shown on the screen, with the right of the screen being at camera x + screen width.
Return Type - Double
Signatures
Camera Y
Returns the y location of the camera in game coordinates. This represents the stop most y value shown on the screen, with bottom of screen being at camera y + screen height.
Return Type - Double
Signatures
Center Camera On
Center Camera On
Set the camera view to be centered over the specific sprite. The offset vector allows you to move the sprite from the direct center of the screen.
Parameters
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to track. |
offset | Vector 2d | The amount to offset the camera, allowing you to position |
the sprite away from the center of the screen. |
Signatures
Center Camera On
Set the camera view to be centered over the specific sprite. The offset vector allows you to move the sprite from the direct center of the screen.
Parameters
Name | Type | Description |
---|---|---|
s | Sprite | The sprite to track. |
offset_x | Double | An additional offset added to the camera, allowing you to |
position the sprite offset from the center of the screen. | ||
offset_y | Double | An additional offset added to the camera, allowing you to |
position the sprite offset from the center of the screen. |
Signatures
Move Camera By
Move Camera By
Move the camera (offset its world x and y values) using the specified vector. For example, if you move the camera by the same speed vector of a sprite the camera will βtrackβ (be locked on to) the sprite as it moves.
Parameters
Name | Type | Description |
---|---|---|
offset | Vector 2d | The amount to move the camera. |
Signatures
Move Camera By
Move the camera (offset its world x and y values) using the specified dx (change in x) and dy (change in x) values.
Parameters
Name | Type | Description |
---|---|---|
dx | Double | The amount to move the camera along the x axis. |
dy | Double | The amount to move the camera along the y axis. |
Signatures
Move Camera To
Move Camera To
Move the camera view (screen top left) to a specified point in the world. This will be the new top left corner of the screen.
Parameters
Name | Type | Description |
---|---|---|
pt | Point 2d | The new camera location |
Signatures
Move Camera To
Move the camera view to a world location specified by the x and y values. This will be the new top left corner of the screen.
Parameters
Name | Type | Description |
---|---|---|
x | Double | The new camera x location |
y | Double | The new camera y location |
Signatures
Point In Window
Tests if the point is in the window.
Parameters
Name | Type | Description |
---|---|---|
wind | Window | The window to check |
pt | Point 2d | The point to check. |
Return Type - Boolean
Signatures
Point On Screen
Tests if the point is on the screen.
Parameters
Name | Type | Description |
---|---|---|
pt | Point 2d | The point to check. |
Return Type - Boolean
Signatures
Rect In Window
Tests if the rectangle is within the bounds of the window.
Parameters
Name | Type | Description |
---|---|---|
wind | Window | The window to check |
rect | Rectangle | The rectangle to check. |
Return Type - Boolean
Signatures
Rect On Screen
Tests if the rectangle is on the screen.
Parameters
Name | Type | Description |
---|---|---|
rect | Rectangle | The rectangle to check. |
Return Type - Boolean
Signatures
Screen Center
Returns the center of the screen in world coordinates.
Return Type - Point 2d
Signatures
Screen Rectangle
Returns a rectangle that represents the dimensions of the window.
Return Type - Rectangle
Signatures
Set Camera Position
Change the position of the camera to a specified world coordinate. This will then be the new top left most position of the screen within the world.
Parameters
Name | Type | Description |
---|---|---|
pos | Point 2d | The new location of the camera. |
Signatures
Set Camera X
Change the X position of the camera to a specified world coordinate. This will then be the new left most position of the screen within the world.
Parameters
Name | Type | Description |
---|---|---|
x | Double | The new x coordinate for the camera |
Signatures
Set Camera Y
Change the Y position of the camera to a specified world coordinate. This will then be the new top most position of the screen within the world.
Parameters
Name | Type | Description |
---|---|---|
y | Double | The new y coordinate for the camera |
Signatures
To Screen
To Screen
Convert the passed in world coordinates to screen coordinates.
Parameters
Name | Type | Description |
---|---|---|
pt | Point 2d | The point to convert - this should be in world coordinates. |
Return Type - Point 2d
Signatures
To Screen
Convert the rectangle in world coordinates to screen coordinates.
Parameters
Name | Type | Description |
---|---|---|
rect | Rectangle | The rectangle to convert - this should be in world coordinates. |
Return Type - Rectangle
Signatures
To Screen X
Translate a world x value to the current screen x value which is based on the camera position.
Parameters
Name | Type | Description |
---|---|---|
world_x | Double | The value of the x coordinate to translate to screen. |
Return Type - Double
Signatures
To Screen Y
Translate a world y value to the current screen y value set by the camera.
Parameters
Name | Type | Description |
---|---|---|
world_y | Double | The value of the y coordinate to translate to screen. |
Return Type - Double
Signatures
To World
Converts the passed in point from screen coordinates to world coordinates.
Parameters
Name | Type | Description |
---|---|---|
pt | Point 2d | The point in screen coordinates. |
Return Type - Point 2d
Signatures
To World X
Translate a screen x value (based on the camera) to a world x value
Parameters
Name | Type | Description |
---|---|---|
screen_x | Double | The value of the x coordinate on screen to translate to |
the world. |
Return Type - Double
Signatures
To World Y
Translate a screen y value (based on the camera) to a world y value
Parameters
Name | Type | Description |
---|---|---|
screen_y | Double | The value of the y coordinate on screen to translate to |
the world. |
Return Type - Double
Signatures
Vector World To Screen
Returns a vector that can transform points from world to screen coordinates.
Return Type - Vector 2d
Signatures
Window Area
Returns a rectangle that represents the dimensions of the window based on the camera.
Parameters
Name | Type | Description |
---|---|---|
wind | Window | The window |
Return Type - Rectangle
Signatures