2.2 KiB
2.2 KiB
Manager
inherits SubViewport
Usage
This is the backbone of the demo.
The Manager
is responsible for the scene management and background music.
Setup
- Create a new scene with a type of
Manager
and make it the main scene. - Set the
Bgm
from either in-editor or through code. - Add scenes to be run in order with
register_scene()
- Create a child of type
AnimationPlayer
and create a new animation with aCall Method Track
- Add keyframes at points where you wish the scene to be changed. Call method
set_scene(scene_number)
. - Call
start_audio()
and$AnimationPlayer.play()
to start the bgm and scene timeline
Example script
extends Manager
var scene1: PackedScene = preload("res://entities/scene_1.tscn");
var scene2: PackedScene = preload("res://entities/scene_2.tscn");
var scene3: PackedScene = preload("res://entities/scene_3.tscn");
var scene4: PackedScene = preload("res://entities/scene_4.tscn");
func _ready() -> void:
register_scene(scene1);
register_scene(scene2);
register_scene(scene3);
register_scene(scene4);
start_audio();
$AnimationPlayer.play("timeline");
Properties
Type | Name | Default |
---|---|---|
String |
bgm | Null |
Array[PackedScene] |
scenes | Array[PackedScene] |
int |
beat_count (unused) | Null |
bgm
Stores the path to the background music as String
scenes
stores the registered scenes. Usually you shouldn't edit this manually
beat_count
Unused
Methods
Returns | Name |
---|---|
void |
set_scene(number: int) |
void |
register_scene(scene: PackedScene) |
void |
start_audio() |
set_scene(number: int)
Changes the current scene to the scene at index number
in scenes
register_scene(scene: PackedScene)
Registers the scene
to the manager.
Each registered scene is added to scenes
and gets preloaded into memory.
The scene number is the scene's index in scenes
, so the first scene registered gets number 0
, the next one gets number 1
and so on.
start_audio()
Calling this function will start playing back the bgm
on the main bus.