scene changeTo is not working within fixedUpdater
- Dominant language
- Kotlin
- Stars
- 3k
- Forks
- 148
- Avg merge
- 13h 44m
- Merged PRs (30d)
- 1
Description
Hello, I am trying to change scene when player's health goes to 0.
I wrote my code as below to check player's health every 1 seconds, and if health goes to under 0, the scene will change to the end scene.
```
addFixedUpdater(time = 1.seconds) {
if(health <= 0) {
launch {
sceneContainer.changeTo({ SceneEnd() })
}
}
}
```
I got error log like below, and the scene does not changed.
I/System.out: Changing scene to... class com.lok.dev.korgegame.scene.SceneEnd (Kotlin reflection is not available) ... com.lok.dev.korgegame.scene.SceneEnd@241a353
W/System.err: kotlinx.coroutines.JobCancellationException: Job was cancelled; job=JobImpl{Cancelled}@d8e0189
If I use changeTo function without FixedUpdater and launch, it works well.
Contributor guide
No contributing guide indexed for this repository
Research direction
Reproduce the report using the shown fixedUpdater, health check, launch, and sceneContainer.changeTo({ SceneEnd() }) flow. Start by tracing the fixedUpdater and scene change lifecycle around the reported JobCancellationException; done means changing scenes from the updater works without the job being cancelled.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin
- Domain
- game-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100