-
Notifications
You must be signed in to change notification settings - Fork 0
Engine
Engine is the hearth of the United framework. You have to declare manually your scene to the framework to load correctly your game.
A scene object is an abstracted component for the Engine. We made this class to set a clear separation. Also we made some other action on this object like a scenePath verification.
Make a "global" script on your superpowers project (put it under the framework). And now register your main scenes to the engine (example code from Echo of life) :
interface Game {
hud?: United.HUD;
player?: Sup.Actor;
control?: PlayerControl;
camera?: Sup.Actor;
playerSpeed?: number;
echo?: Echo;
triggers?: EventEmitter;
paused?: boolean;
isEnd?: boolean;
}
const DefaultChunk : United.Collections.Chunk<Game> = new United.Collections.Chunk<Game>({
control: new PlayerControl(),
triggers: new EventEmitter(),
paused: false,
isEnd: false
});
const U_Scene_Level1: United.Scene<Game> = new United.Scene<Game>({
name: "Level1",
asset: "Projet/Scenes/Level1",
chunk: DefaultChunk.clone()
});
const U_Scene_Level2: United.Scene<Game> = new United.Scene<Game>({
name: "Level2",
asset: "Projet/Scenes/Level2",
chunk: DefaultChunk.clone()
});
United.Engine.activeScene = "Level1";
In this case you have to understand that the chunk represent "global" variables recheable in our game. Chunk provide cool features like easy reseatable triggers, and soon mapping/observable system.
Do not use the Superpowers "loadScene" but use the United.Engine.activeScene = "Level2"
. The Engine have to make a bulk of modification into the core for switching correctly between scenes (Like chunk & addons clearing).
The Engine do the work solo. Another features linked to the Engine are in link with Addons.
Return the global Chunk.
static get $<T>() : United.Collections.Chunk<T>
Know if the engine have a registered Scene
static hasScene(sceneName: string) : boolean
Register a new addon into the current active Scene or into a specific sub scene.
static registerAddon<T extends United.Addons>(addon: T,scene?: string) : boolean
Know if the current have the following addon registered
static ifAddonRegistered<T extends United.Addon> (addon: T): boolean
Restrict a chunk. Unstable feature for now.
static restrictChunk<T>(chunk: United.Collections.Chunk<T> , sceneName: string) : void
Add a new main scene to the engine!
static addScene(name: string,assetPath: string) : boolean
Load a new main scene.
static loadScene(name: string) : boolean
Break the entiere game.
static break(sleepTime?:number) : void
Dont use it (the main while already use it by default).
static update() : void
- Add support for SceneSchema. Ability to create a multiple entry of the same scene configuration. Very usefull for a game oriented "scenes levels".
- Better typings.
- Ability to get
$
when event emitting.
Contributor :
- Fraxken
- Purexo