Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add FXGL simple example #11

Open
AlmasB opened this issue Jul 20, 2021 · 4 comments
Open

Add FXGL simple example #11

AlmasB opened this issue Jul 20, 2021 · 4 comments

Comments

@AlmasB
Copy link

AlmasB commented Jul 20, 2021

Hi @makingthematrix

Following our quick chat on Twitter, please see a standalone example below:

Maven dep coordinates:

<dependency>
    <groupId>com.github.almasb</groupId>
    <artifactId>fxgl</artifactId>
    <version>11.17</version>
</dependency>

Example:

import com.almasb.fxgl.app.GameApplication;
import com.almasb.fxgl.app.GameSettings;
import com.almasb.fxgl.dsl.FXGL;
import javafx.scene.text.Text;

public class UISample extends GameApplication {

    @Override
    protected void initSettings(GameSettings settings) { }

    @Override
    protected void initUI() {
        Text uiText = new Text("Hello World");

        FXGL.addUINode(uiText, 100, 100);
    }

    public static void main(String[] args) {
        launch(args);
    }
}

The example, when executed, will open a 800x600 window with "Hello World" text.

@makingthematrix
Copy link
Owner

I decided to write a bit more comlicated example so I could try it out together with Gluon Mobile: https://github.com/makingthematrix/scalaonandroid/tree/main/HelloFXGL

It turns out there's no problem with using FXGL from Scala, but there is a problem with using FXGL on Android - there is no support yet for AWT on Android :(
I described my work in details in the readme file for HellFXGL (under that link above). Do you think anything can be done about it from your side? Or should I talk to Gluon?

@AlmasB
Copy link
Author

AlmasB commented Jul 22, 2021 via email

@AlmasB
Copy link
Author

AlmasB commented Jul 22, 2021

Right, the issue is with the graalvm version I believe. I tried this with one of the latest stable builds and got the same runtime error. Version 20.2.0 works fine though. As far as I'm aware this is will be fixed eventually, but I wonder what exactly triggers this awt load call -- will check.

Thanks for the Scala example!

@makingthematrix
Copy link
Owner

@AlmasB : I was able to get the error with only adding FXGL to dependencies, without using it in the code. Maybe one of FXGL dependencies uses AWT?... I wrote about it in a comment here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants