AlmasB / FXGLGames

This repo contains sample games built with FXGL
http://almasb.github.io/FXGLGames/
MIT License
807 stars 325 forks source link

Can't load resources after modularized #5

Open LaiZhou opened 4 years ago

LaiZhou commented 4 years ago
<plugin>
                <groupId>org.openjfx</groupId>
                <artifactId>javafx-maven-plugin</artifactId>
                <version>0.0.4</version>
                <configuration>
                    <stripDebug>true</stripDebug>
                    <compress>2</compress>
                    <noHeaderFiles>true</noHeaderFiles>
                    <noManPages>true</noManPages>
                    <release>${source.version}</release>
                    <jlinkImageName>FlappyBird</jlinkImageName>
                    <launcher>FlappyBird</launcher>
                    <mainClass>FlappyBird/com.almasb.fxglgames.flappy.FlappyBirdApp</mainClass>
                </configuration>
            </plugin> 

I used jlink to generate executable binary , but when I execute command ,it reported the error:

Failed to load texture bird.png Error: java.lang.IllegalArgumentException: Asset "/assets/textures/bird.png" was not found!

How to generate the correct executable binary on Windows? I want to get an .exe file finally.

LaiZhou commented 4 years ago

found a related issue. https://github.com/AlmasB/FXGL/issues/644

LaiZhou commented 4 years ago

Update.

module FlappyBird {
  requires com.almasb.fxgl.all;
  opens assets.music;
  opens assets.sounds;
  opens assets.textures;

  opens com.almasb.fxglgames.flappy;
  exports  com.almasb.fxglgames.flappy;
}

I try to create every sub-pakcage of assets ,and opens them, it reported new error:

[JavaFX Application Thread] WARN  AssetLoader          - Failed to load sound jump.wav Error: java.lang.UnsupportedOperationException: Unsupported protocol "jrt"

It seems like an openJdk bug.

LaiZhou commented 4 years ago

@AlmasB

AlmasB commented 4 years ago

Hi, you can open the module without opening each asset. So,

open module ...{

}

LaiZhou commented 4 years ago
open module FlappyBird {
  requires com.almasb.fxgl.all;
  exports  com.almasb.fxglgames.flappy;
}

@AlmasB I tried it, still failed, it showed the same error. The steps. execute the command

mvn clean install
mvn javafx:jlink

run the FlappyBird.bat

AlmasB commented 4 years ago

Thanks, I'll check it out later today

On Tue, 11 Feb 2020, 8:55 am LaiZhou, notifications@github.com wrote:

open module FlappyBird { requires com.almasb.fxgl.all; exports com.almasb.fxglgames.flappy; }

I tried it, still failed, it showed the same error. The steps. execute the command

mvn clean install

mvn javafx:jlink

run the FlappyBird.bat

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/AlmasB/FXGLGames/issues/5?email_source=notifications&email_token=AA3NT5U6DNN2KSKF6ZCYIRTRCJRXDA5CNFSM4KSHX2IKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOELLT7VI#issuecomment-584531925, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA3NT5UFNK73MHQ653IRLRLRCJRXDANCNFSM4KSHX2IA .

AlmasB commented 4 years ago

Yes, with open module I also get Unsupported protocol "jrt". I seem to recall that javafx-media is not yet available natively, which is likely what's causing the issue. For more details, you can talk to the Gluon team, I think they are releasing the native javafx-media support soon.