#JavaFX scene isnt switching once number hits 0
1 messages · Page 1 of 1 (latest)
<@&987246487241105418> please have a look, thanks.
Your error is about multi-threading.
The timer task runs on its own thread which is different from the thread that creates the UI and renders it.
In most UI frameworks there is a technical need for the change of a value on the UI to occur in the thread that runs the UI.
Because of that most frameworks implement a stack of actions to be executed on the UI thread and give the user some convenient way to add items to it.
In JavaFX that is Platform.runLater() which adds whatever action you send into it to the stack of actions the UI thread will execute soon.
Here the thing you set on the ui thread obviously enough is setting the scene, so instead that needs to happen in an action you send to the UI thread via Platform.runLater
Its actually an issue with whatever was line 106 like your error message says. I have no idea whether your .attack() modifies something on the ui thread
The important thing to understand here is that any time you set a setting on something in the ui from another thread, you need to wrap i in a runLater call
this attack fn probably qualifies since i'm assuming circle is a ui element
ye
so how would i do that? ive never used timers or runeLaters before
so its all new to me