scene¶
- class scene
A high level scene structure used that integrates object hierarchy, rendering, input, physics and serialisation to simplify and streamline games and simulations
- main: scene¶
Sets the main Codea scene, which will be automatically drawn, updated and handle touch events
function setup() scene.main = scene.default3d() end
- static default3d([name])¶
Creates the default 3D scene containing a perspective camera, directional light and HDR environment, with an optional name
- Return type:
scene
- static default2d([name])¶
Creates the default 2D scene containing an orthographic camera, with an optional name
- Return type:
scene
- static read(key)¶
Loads and returns a scene with the supplied asset key
- Return type:
scene
- static save(key, scene)¶
Saves the supplied scene at the given asset key location
- name: string¶
Gets or sets a name for this scene
- world2d: physics2d.world¶
Gets the scene’s 2D physics world, providing access to various physics functions and properties such as
physics2d.world.applyForce()
- world3d: physics3d.world¶
Gets the scene’s 3D physics world, providing access to various physics functions and properties such as
physics3d.world.applyForce()
- sky: None¶
Sets the sky visuals, which will depend on the type used:
asset.key
- Use an image pointed to by a given asset keyimage
- Use an image directly (assumed to be a cube image)color
- Use a solid color
- entities([activeOnly = true])¶
Returns a table containing all root entities
- Parameters:
activeOnly – When set, returns only active root entities
- Return type:
- index(name) [metamethod]
Returns the root entity with the given name (if it exists)
- Return type:
- draw()¶
Immediately draws the scene to the current context. When autoUpdate is enabled,
update(dt)
will be called as wellIf set as
scene.main
this will be called automatically right before the globaldraw()
function
- update(deltaTime)¶
Updates the scene, called automatically when
draw()
is called but can also be called manutally if needed