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
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 key

  • image - Use an image directly (assumed to be a cube image)

  • color - Use a solid color

camera: entity
Returns:

The scene’s camera entity (if it exists)

Return type:

entity

sun: entity
Returns:

The scene’s sun entity (if it exists)

Return type:

entity

entity([name])

Creates a new blank entity with an optional name

findEntity(name)
entities([activeOnly = true])

Returns a table containing all root entities

Parameters:

activeOnly – When set, returns only active root entities

index(name) [metamethod]

Returns the root entity with the given name (if it exists)

draw()

Immediately draws the scene to the current context. When autoUpdate is enabled, update(dt) will be called as well

If set as scene.main this will be called automatically right before the global draw() function

update(deltaTime)

Updates the scene, called automatically when draw() is called but can also be called manutally if needed