new Scene(canvas, initFunc, simulationFunc, drawFunc)
A Scene handles the render loop for the game. Inside of initFunc, simulationFunc, and drawFunc `this` refers to the current scene.
Parameters:
Name | Type | Description |
---|---|---|
canvas |
external:canvas | The canvas to render on. |
initFunc |
emptyCallback | A callback to be called every time the Scene is started. |
simulationFunc |
simulationCallback | A callback that updates the state of the game's simulation. |
drawFunc |
drawCallback | A callback that draws the game. |
Members
camera :Splat.Camera
The Camera used to offset the Scene's drawing.
This Camera's move and draw methods are called automatically for you. The default Camera starts at the origin (0,0).
Type:
showFrameRate :boolean
A flag that enables/disables a frame rate counter in the corner of the screen. This is useful during development.
Type:
- boolean
timers :object
A key-value store of named timers. Timers in this object will be automatically tick()ed for you when the scene is running..
Type:
- object
Methods
reset()
Reset the simulation by re-running the Splat.Scene#initFunc.
start()
Start running the scene.
stop()
Stop running the scene.