[Embeded mode]How to set the default task for loading scene? #1087
-
Hi: Each time when the game starts, we hope to load some resources which may take some times Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 7 replies
-
Hmm.... @Override
public void onCreate() {
var task = new Task<Void>(){
@Override
protected Void call() throws Exception {
updateProgress(0,100);
FXGL.image("player" + separator + "upper.png", 1400 /2, 350 /2);
updateProgress(20,100);
FXGL.image("player" + separator + "run.png", 2880/2, 220/2);
updateProgress(40,100);
FXGL.image("player" + separator + "jump.png", 2400/2, 220/2);
updateProgress(60,100);
FXGL.image("player" + separator + "fire.png", 4500/2, 250/2);
updateProgress(80,100);
return null;
}
};
progressProp.bind(task.progressProperty());
new Thread(task).start();
} but not sure this is the right way to do it |
Beta Was this translation helpful? Give feedback.
-
Have a look at this sample, perhaps something useful there? |
Beta Was this translation helpful? Give feedback.
-
There is no need to explicitly call
|
Beta Was this translation helpful? Give feedback.
There is no need to explicitly call
loading()
sinceinitGame()
already runs on a background thread. While initGame() runs, FXGL will display the loading scene, which can be customized. So: