美文网首页
fxgl - 2 - hello world

fxgl - 2 - hello world

作者: 裸奔的刺猬 | 来源:发表于2022-06-29 15:01 被阅读0次

PS:禁止拷贝形式转载,转载请以URL形式

PS:FXGL 准备写成一个系列,所以在该系列未完成前,该系列文章除了目录会被修改其他内容均可能被删改。

1.环境

  1. 本学习记录都是基于java 17 ,毕竟自己学习项目新版本搁着使劲用没有亿点点负担~
  2. maven环境本人3.6

2. hello world

  • 效果

    image.png
  • 文件总览

    image.png
  • POM
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>priv.dyf.fxgl</groupId>
    <artifactId>stu</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>17</maven.compiler.source>
        <maven.compiler.target>17</maven.compiler.target>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-controls</artifactId>
            <version>17.0.2</version>
        </dependency>
        <dependency>
            <groupId>com.github.almasb</groupId>
            <artifactId>fxgl</artifactId>
            <version>17.1</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.0</version>
                <configuration>
                    <release>17</release>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.openjfx</groupId>
                <artifactId>javafx-maven-plugin</artifactId>
                <version>0.0.6</version>
                <executions>
                    <execution>
                        <!-- Default configuration for running -->
                        <!-- Usage: mvn clean javafx:run -->
                        <id>default-cli</id>
                        <configuration>
                            <mainClass>priv.dyf.fxgl.stu.StuApp</mainClass>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>
  • StuApp
package priv.dyf.fxgl.stu;

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

/**
 * @ClassName
 * @Description
 * @Author dyf
 * @Date 2022/6/29
 * @Version 1.0
 */
public class StuApp extends GameApplication {
    @Override
    protected void initSettings(GameSettings gameSettings) {
        gameSettings.setTitle("HELLO FXGL");
        gameSettings.setVersion("1.0");
    }

    @Override
    protected void initUI() {
        Text text = FXGL.getUIFactoryService().newText("HELLO FXGL", Color.BLACK, 22);
        FXGL.addUINode(text,FXGL.getAppCenter().getX(),FXGL.getAppCenter().getY());
    }

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

  • module-info.java
open module stu {
    requires com.almasb.fxgl.all;
}

相关文章

  • fxgl - 2 - hello world

    PS:禁止拷贝形式转载,转载请以URL形式 PS:FXGL 准备写成一个系列,所以在该系列未完成前,该系列文章除了...

  • Hello World

    Hello World 1 Hello World 2## Hello World 3 Hello World 4...

  • Hello, World!

    标题H1: #Hello, world! Hello, world! H2: ##Hello, world! He...

  • This is a test

    Blog Test Chapter 1 Hello world Chapter 1.1 Hello world 2...

  • Docker入门命令

    1、Hello World 首先$ docker run ubuntu echo hello world 2、简单...

  • 常用markdown语法

    Hello World! Hello World! Hello World! Hello World! Hello...

  • hello

    hello, world hello, world hello, world hello, world

  • Markdown

    标题: hello world hello world hello world hello world hello...

  • 2018-06-11

    markdown hello world hello world hello world hello world ...

  • hello

    hello world 1 2

网友评论

      本文标题:fxgl - 2 - hello world

      本文链接:https://www.haomeiwen.com/subject/pentbrtx.html