Skip to content

Commit

Permalink
impl: start_neighbor_scene
Browse files Browse the repository at this point in the history
  • Loading branch information
gnlow committed Dec 5, 2023
1 parent 7ff12dc commit ad8e45e
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/Entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export class Entry {
objects: Record<string, EntrySprite> = {}

pressedKeys: Record<number, boolean | undefined> = {}
currentScene: Container

timer = new Timer()

Expand All @@ -52,6 +53,7 @@ export class Entry {
}
)
)
this.currentScene = Object.values(this.scenes)[0]
}
async init(parent: HTMLElement) {
this.variables = Object.fromEntries(
Expand Down Expand Up @@ -142,7 +144,7 @@ export class Entry {
}
render() {
this.renderer!.render({
container: Object.values(this.scenes)[0]
container: this.currentScene
})
}
wait_tick() {
Expand All @@ -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) {
Expand Down

0 comments on commit ad8e45e

Please sign in to comment.