Skip to content

Commit

Permalink
ロード完了イベントが意図せず複数回発生するバグを修正
Browse files Browse the repository at this point in the history
  • Loading branch information
3w36zj6 committed Nov 9, 2023
1 parent 645128b commit 72f8120
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/scene/PlayScene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export class PlayScene extends Phaser.Scene {

private loadEndTime?: Date

private isLoading: boolean
private hasLoaded: boolean
private hasFadedOut: boolean

Expand Down Expand Up @@ -95,6 +96,8 @@ export class PlayScene extends Phaser.Scene {

this.loadEndTime = undefined

this.isLoading = false

this.hasLoaded = false

this.hasFadedOut = false
Expand Down Expand Up @@ -154,6 +157,7 @@ export class PlayScene extends Phaser.Scene {
this.keySoundPlayer = new KeySoundPlayer(this.chart)
this.keySoundPlayer.loadKeySounds(this, url)
this.load.start()
this.isLoading = true
})
.catch((error: AxiosError) => {
console.log(error)
Expand Down Expand Up @@ -472,6 +476,9 @@ export class PlayScene extends Phaser.Scene {
this.debugText.setText(`${value}`)
})
this.load.on("complete", () => {
if (!this.isLoading || this.hasLoaded) {
return
}
this.hasLoaded = true
this.loadEndTime = new Date()
this.cameras.main.fadeIn(500)
Expand Down

0 comments on commit 72f8120

Please sign in to comment.