Rendering.Scene2d

Description: Defines a scene object that is used to maintain a list of renderable objects that are rendered onto a joint game area.

Implements: EndGate.IDisposable

Constructors

Scene2d ()
Creates a new instance of the Scene2d object. The game canvas is created and appended to the HTML body to fill the screen.

Scene2d (onDraw)
Creates a new instance of the Scene2d object. The game canvas is created and appended to the HTML body to fill the screen.

onDraw: (context: CanvasRenderingContext2D) => void
Callback to execute whenever the Scene's draw is triggered.

Scene2d (onDraw, drawArea)
Creates a new instance of the Scene2d object.

onDraw: (context: CanvasRenderingContext2D) => void
Callback to execute whenever the Scene's draw is triggered.

drawArea: HTMLCanvasElement
The game canvas to draw onto.

Fields

DrawArea: HTMLCanvasElement
Gets the canvas that the Scene2d uses as its game area.

Camera: Rendering.Camera2d
Gets the game camera.

Methods

Add()
Adds an actor to the scene. All actors added to the scene have their Draw function called automatically.

Remove()
Removes an actor from the scene. The actor will no longer have its Draw called.

Draw()
Draws all actors within the Scene and triggers the Scene2d's onDraw callback.

Dispose()
Destroys the game canvas and clears the Scene2d's actors.

Examples

There's currently no example available for this page. If you'd like to suggest one send me an containing a description, code, and link to the page for the suggested example. As a thanks I'll associate the code snippet with your name directly below the example if approved.