Skip to main content

Scene.js

Scene

Create a new scene

Kind: global class
Constructors:

Scene.addChild(child) ⇒ Scene

Add a child to the scene

Kind: static method of Scene
Returns: Scene -

This scene

ParamTypeDescription
childImpacto.GameObject

The child to add

Example

this.addChild(mySprite);

Scene.removeChild(child) ⇒ Scene

Remove a child from the scene

Kind: static method of Scene
Returns: Scene -

This scene

ParamTypeDescription
childImpacto.GameObject

The child to remove

Example

this.removeChild(mySprite);

Scene.start()

The entry point of the scene, this function is called once when the scene is loaded Normally, you use this function to create and add your game objects

Kind: static method of Scene
Example

class MyScene extends Scene {
start() {
const sprite = new Sprite();
this.addChild(sprite);
}
}

Scene.update(delta)

The update function is called every frame

Kind: static method of Scene

ParamTypeDescription
deltanumber

The time since the last frame

Example

class MyScene extends Scene {
update(delta) {
console.log(delta);
}
}

Scene.posRender(context)

The render function is called every frame after the update and core render function

Kind: static method of Scene

ParamTypeDescription
contextCanvasRenderingContext2D

The canvas context

Example

class MyScene extends Scene {
render(context) {
console.log("render");
}
}