Search in sources :

Example 1 with ScoreData

use of com.almasb.fxgl.gameplay.ScoreData in project FXGL by AlmasB.

the class RESTClientSample method initInput.

@Override
protected void initInput() {
    onKeyDown(KeyCode.Q, "Get Top", () -> {
        getGameplay().getLeaderboard().loadTopTask(5).onSuccess(scores -> scores.forEach(System.out::println)).executeAsyncWithDialogFX(new ProgressDialog("Connecting to FXGL server"));
    });
    onKeyDown(KeyCode.E, "Put New Score", () -> {
        getGameplay().getLeaderboard().postNewScoreTask(new ScoreData("AlmasB", 9999)).onSuccess(n -> System.out.println("Success put")).executeAsyncWithDialogFX(new ProgressDialog("Uploading to FXGL server"));
    });
}
Also used : KeyCode(javafx.scene.input.KeyCode) DSLKt.onKeyDown(com.almasb.fxgl.app.DSLKt.onKeyDown) GameSettings(com.almasb.fxgl.settings.GameSettings) GameApplication(com.almasb.fxgl.app.GameApplication) ProgressDialog(com.almasb.fxgl.scene.ProgressDialog) ScoreData(com.almasb.fxgl.gameplay.ScoreData) ProgressDialog(com.almasb.fxgl.scene.ProgressDialog) ScoreData(com.almasb.fxgl.gameplay.ScoreData)

Aggregations

DSLKt.onKeyDown (com.almasb.fxgl.app.DSLKt.onKeyDown)1 GameApplication (com.almasb.fxgl.app.GameApplication)1 ScoreData (com.almasb.fxgl.gameplay.ScoreData)1 ProgressDialog (com.almasb.fxgl.scene.ProgressDialog)1 GameSettings (com.almasb.fxgl.settings.GameSettings)1 KeyCode (javafx.scene.input.KeyCode)1