Camera 2D
Renders an orthographic view from the node transform.
component engine.Camera2D
On this page
Usage
Add it with Create → Camera → Camera.
Try it
Camera 2D zoom
The camera frames a row of colored sprites. A higher zoom makes them appear larger.
Change Zoom from 32 to 64 and watch the Game View; Reset restores the original framing.
Scene6 nodes
Fields
| Name | Type | Default | Description |
|---|---|---|---|
| Zoom | float | 64 | Pixels per world unit. Larger values show a smaller part of the world. ≥ 0.01 |
| Viewport | Rect | (0, 0, 1, 1) | Part of the screen the camera draws into, in normalized coordinates. |
| Mask | int | -1 | Visibility layers this camera renders. -1 renders every layer. |
| Order | int | 0 | Cameras with a lower order render first. |
| Clear | bool | true | Clears the viewport before drawing. |
| Clear Color | Color | rgba(0.04, 0.05, 0.07, 1) | Background color used when clear is on. |
| Scale | enum | free | How the view adapts to the window: free, pixelPerfect or fitVirtual. one of: free, pixelPerfect, fitVirtual |
| Virtual | Vec2 | (0, 0) | Virtual resolution used by fitVirtual and pixelPerfect. |
| Active | bool | true | Only active cameras render. |
From a script
Zoom the camera in smoothly while a key is held, and back out when it is released.
package game
import (
"aego/input"
"aego/math"
)
script ZoomCamera {
var Normal float = 40
var Close float = 80
func Update(dt float) {
cam := node.Get<Camera2D>()
target := Normal
if input.Down(input.KeyZ) {
target = Close
}
cam.Zoom = math.Lerp(cam.Zoom, target, math.Clamp(dt*6, 0, 1))
}
}
Related guides
- Cameras Camera2D renders an orthographic view from the node's 2D transform.
- Cameras 2D A Camera 2D draws the view; virtual cameras decide where it looks.
- Art Studio: drawing, frames and source files Create a drawing, edit layers and frames, then distinguish saving its source from publishing game assets.