Install FXGL using Gradle
devAdd the following to your build.gradle file. Note that you may need to include jcenter() in your repositories block.
repositories {
jcenter()
}
dependencies {
compile 'com.github.almasb:fxgl:25'
}repository·dev·Indexed 26 days ago
https://github.com/almasb/fxglA JavaFX-based game development framework for 2D games and complex UI applications. It supports Java 8-25 across Windows, Mac, Linux, Android, iOS, and Web. FXGL provides high-level APIs for entity-component systems, animations, particles, network communication via Client and Server classes, dialogue trees using DialogueGraph, and specialized rechargeable components for health and mana.
Add the following to your build.gradle file. Note that you may need to include jcenter() in your repositories block.
repositories {
jcenter()
}
dependencies {
compile 'com.github.almasb:fxgl:25'
}Add the FXGL dependency to your build.gradle file. Ensure you have the appropriate repository configured.
repositories {
jcenter()
}
dependencies {
compile 'com.github.almasb:fxgl:25'
}If you are developing a modular Java application (using JPMS), include the following module-info.java configuration to require the FXGL module.
open module app.name {
requires com.almasb.fxgl.all;
}Add the following dependency to your pom.xml file to include FXGL in your Java or Kotlin project.
<dependency>
<groupId>com.github.almasb</groupId>
<artifactId>fxgl</artifactId>
<version>25</version>
</dependency>Add the following dependency to your pom.xml to use FXGL in your Maven project. The current version is 25.
<dependency>
<groupId>com.github.almasb</groupId>
<artifactId>fxgl</artifactId>
<version>25</version>
</dependency>If you are developing a modular application using the Java Module System, include the following requirement in your module-info.java file to access the FXGL API.
open module app.name {
requires com.almasb.fxgl.all;
}If you are developing a modular application using the Java Module System, add the following requirement to your module-info.java file to access the FXGL API:
open module app.name {
requires com.almasb.fxgl.all;
}To create a minimal FXGL game, extend the GameApplication class and override the initSettings(GameSettings settings) method to configure window properties like width, height, and title. Use GameApplication.launch(args) in the main method to start the application.
public class BasicGameApp extends GameApplication {
@Override
protected void initSettings(GameSettings settings) {
settings.setWidth(800);
settings.setHeight(600);
settings.setTitle("Basic Game App");
}
public static void main(String[] args) {
launch(args);
}
}To create a basic FXGL application, extend the GameApplication class and override the initSettings(GameSettings settings) method to configure your game's window properties such as width, height, and title. Use GameApplication.launch(args) in your main method to start the application.
Supported platforms include Windows, Mac, Linux, Android 8+, iOS 11.0+, and Web. It supports Java 8 through 25.
public class BasicGameApp extends GameApplication {
@Override
protected void initSettings(GameSettings settings) {
settings.setWidth(800);
settings.setHeight(600);
settings.setTitle("Basic Game App");
}
public static void main(String[] args) {
launch(args);
}
}ReplicationEvent is automatically replicated to the other endpoint of a network connection. You can extend this class to create custom network events or listen for built-in replication events using the provided EventType constants.