From ad8e45eec4dcfd9d1f0c7abd35f525efc8692af9 Mon Sep 17 00:00:00 2001 From: Gnlow Date: Tue, 5 Dec 2023 10:41:11 +0900 Subject: [PATCH] impl: start_neighbor_scene --- src/Entry.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Entry.ts b/src/Entry.ts index fa0e7ff..a51e311 100644 --- a/src/Entry.ts +++ b/src/Entry.ts @@ -32,6 +32,7 @@ export class Entry { objects: Record = {} pressedKeys: Record = {} + currentScene: Container timer = new Timer() @@ -52,6 +53,7 @@ export class Entry { } ) ) + this.currentScene = Object.values(this.scenes)[0] } async init(parent: HTMLElement) { this.variables = Object.fromEntries( @@ -142,7 +144,7 @@ export class Entry { } render() { this.renderer!.render({ - container: Object.values(this.scenes)[0] + container: this.currentScene }) } wait_tick() { @@ -155,6 +157,15 @@ export class Entry { when_run_button_click(f: () => void) { this.on("start", f) } + start_neighbor_scene(type: "prev" | "next") { + const currentSceneIndex = Object.values(this.scenes).findIndex(scene => scene == this.currentScene) + if (type == "prev") { + this.currentScene = Object.values(this.scenes)[currentSceneIndex - 1] + } + if (type == "next") { + this.currentScene = Object.values(this.scenes)[currentSceneIndex + 1] + } + } /* 흐름 */ wait_second(sec: number) {