I'm trying to make a loading screen for a game that shows whenever a level is being generated. When the game isn't doing anything, the loading screen works just fine. But when I put in the code to generate levels, the loading screen is a blank screen and the application becomes unresponsive until the loading is done. The question is, how can I make it so the level generator doesn't interfere with the loading screen and the rest of the application? I'm using the swing timer to control the loading animation. And I don't want to use threads because the level generator will be used multiple times, and I know that a thread's run method can only be called once.
Asked
Active
Viewed 428 times
1
-
Read up on [concurrency in JavaFX](http://docs.oracle.com/javase/8/javafx/interoperability-tutorial/concurrency.htm). – jewelsea Feb 04 '15 at 00:01
-
@jewelsea Could you possibly show me how to use it? Sorry, I'm just a newbie so the page you referred to me is just too much. – Jaca Feb 04 '15 at 00:14
-
@jewelsea Actually, hold off on that. I want to figure it out for myself. – Jaca Feb 04 '15 at 00:32
-
Great, there are already tons of examples out there if you just google JavaFX concurrency and the [javadoc](http://docs.oracle.com/javase/8/javafx/api/javafx/concurrent/Task.html) is really well written and full of great examples, that I don't think an additional example by me would add much value. That said there is an old example I created for something similar which might help - [JavaFX splash page for an intensive startup task with progress monitoring](https://gist.github.com/jewelsea/2305098). – jewelsea Feb 04 '15 at 02:10
1 Answers
1
I learned from jewelsea that I can use the javafx.concurrent.Task class to help with background processing that is resource heavy.

Jaca
- 197
- 1
- 8