Extends
Members
active :boolean
Wether or not this scene is the active scene and it is being rendered. Best not to set directly. Use engine.switchScene instead.
Type:
- boolean
- Inherited From:
- Default Value:
- false
- Source:
assets :module:core~Assets
A reference to the global Assets plugin.
Type:
- Inherited From:
- Source:
camera :module:core~Camera
The camera object that belongs to this scene.
Type:
- Inherited From:
- Source:
children :Array.<module:gameobjects~GameObject>
The children that are added to the scene. Children will be rendered on top of each other. So a child with a lower index will be behind children with a higher index.
Type:
- Array.<module:gameobjects~GameObject>
- Inherited From:
- Source:
engine :module:core~Engine
A reference to the main engine.
Type:
- Inherited From:
- Source:
listeners :object
A dictionary of the event callbacks attached to this object.
Type:
- object
- Inherited From:
- Source:
name :string
The name you gave this instance of the scene in the game config.
Type:
- string
- Inherited From:
- Source:
options :object
An object that is taken from the game config and passed to a specific scene that was instantiated by the Engine. This way you can use the same scene class, but have multiple instances with different things going on. Available in the init function of the scene, but not in the constructor.
Type:
- object
- Inherited From:
- Source:
plugins :Array.<module:core~ScenePlugin>
An array that holds the scene plugins.
Type:
- Array.<module:core~ScenePlugin>
- Inherited From:
- Source:
viewport :object
Information about the actual size of the viewport and canvas.
Type:
- object
Properties:
Name | Type | Description |
---|---|---|
width |
number | The actual width of the viewport or canvas. Not the one set in the game config. |
height |
number | The actual height of the viewport or canvas. Not the one set in the game config. |
zoom |
number | The actual zoom. Not the one set in the game config. |
- Inherited From:
- Source:
Methods
add(child) → {module:gameobjects~GameObject}
Adds a child to this scene.
Parameters:
Name | Type | Description |
---|---|---|
child |
module:gameobjects~GameObject | The GameObject instance to be added. |
- Inherited From:
- Source:
Returns:
- Returns the child again.
emit(type, eopt)
Emits the event of a certain type and executes all callbacks.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
type |
string | The name of the event it emits. | |
e |
object |
<optional> |
An optional object that will be passed to the callbacks first argument. |
- Inherited From:
- Source:
init()
Starts to load the assets you defined in the game config. And adds a SimpleBar to this scene.
- Overrides:
- Source:
off(typeopt, callbackopt)
Removes listeners from this object.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
type |
string |
<optional> |
The name of the event to remove callback(s) for. If left empty, it will remove every single callback from this object. |
callback |
function |
<optional> |
The callback to remove. If left empty, it will remove all callbacks for the given type or when the type is empty every single callback on this object. |
- Inherited From:
- Source:
on(type, callback)
Continually listen on this object for an event.
Parameters:
Name | Type | Description |
---|---|---|
type |
string | The name of the event. |
callback |
function | The function to execute each time the event is emitted. |
- Inherited From:
- Source:
once(type, callback)
Listen on this object for an event, but execute the callback only once.
Parameters:
Name | Type | Description |
---|---|---|
type |
string | The name of the event. |
callback |
function | The function to execute once. |
- Inherited From:
- Source:
remove(child)
Removes a child from this scene. If the child has a body, the body will be removed from the world.
Parameters:
Name | Type | Description |
---|---|---|
child |
module:gameobjects~GameObject | The GameObject to be removed. |
- Inherited From:
- Source:
render(context, time, delta)
Internal function. Automatically called every frame. Can be overriden, but it is best to call `super.render(context, time, delta)`. Using `update` is the preferred way to go to game logic.
Parameters:
Name | Type | Description |
---|---|---|
context |
CanvasRenderingContext2D | The canvas render context. |
time |
number | The total time (in milliesconds) since the start of the game. |
delta |
number | The time elapsed (in milliseconds) since the last frame. |
- Inherited From:
- Source:
(abstract) resize(w, h)
Automatically called when the browser resizes. Can be used in your own Scene classes to resposition stuff. No need to call `super.resize()`.
Parameters:
Name | Type | Description |
---|---|---|
w |
number | The new width of the game canvas. |
h |
number | The new height of the game canvas. |
- Inherited From:
- Source:
restart()
Simply restart this scene.
- Inherited From:
- Source:
setup()
Internal function for starting the scene again. Use `init` to do your own setup.
- Inherited From:
- Source:
shutdown()
Calls `super.shutdown()` and removes the reference to the SimpleBar instance.
- Overrides:
- Source:
update(time, delta)
Updates the SimpleBar graphic.
Parameters:
Name | Type | Description |
---|---|---|
time |
number | The total time (in milliesconds) since the start of the game. |
delta |
number | The time elapsed (in milliseconds) since the last frame. |
- Overrides:
- Source:
Events
addedchild
Notifies when a child is added to this scene. Passes the child that was added.
Type:
- Inherited From:
- Source:
removedchild
Notifies when a child is removed from this scene. Passes the child that was removed.
Type:
- Inherited From:
- Source: