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
AssetLoader doesn't have access to assets folder in a modular project #644
Comments
I think I tried various approaches. Will check. Does making the end user
module “open” fix that?
…On Mon, 8 Jul 2019 at 12:09 pm, José Pereda ***@***.***> wrote:
When the project is modular, since AssetLoader is in a different module,
it doesn't have access to the assets/sound or assets/texture resources
folders.
Fatal exception occurred: java.lang.IllegalArgumentException : Failed to load asset: brick.png. Cause: Asset "/assets/textures/brick.png" was not found!
E: com.almasb.fxgl.all/com.almasb.fxgl.app.AssetLoader.loadFailed(AssetLoader.kt:628)
E: com.almasb.fxgl.all/com.almasb.fxgl.app.AssetLoader.loadTexture(AssetLoader.kt:158)
E: com.almasb.fxgl.all/com.almasb.fxgl.dsl.FXGL$Companion.texture(FXGL.kt:203)
E: com.almasb.fxgl.all/com.almasb.fxgl.dsl.EntityBuilder.view(EntityBuilder.kt:96)
E: hellofx/org.openjfx.BasicGameApp.initGame(BasicGameApp.java:78)
which is caused by:
GameApplication.FXGLApplication.app?.javaClass?.getResource(name) being
null, in `AssetLoader::getURL.
There are a few options to solve this (using
getClassLoader().getResource() should do it, and it is the simplest way.
Other options involve something more complex like
ModuleLayer.boot().findModule(moduleName)...)
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#644?email_source=notifications&email_token=AA3NT5W7ECCG34TFAXFU5YTP6MN6RA5CNFSM4H62RPMKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4G52KKZQ>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AA3NT5SICEF7QWHSPZVYTCDP6MN6RANCNFSM4H62RPMA>
.
|
No, if you do:
|
I meant
open module bla-bla {
requires com.almasb.fxgl ...
}
…On Mon, 8 Jul 2019 at 12:26 pm, José Pereda ***@***.***> wrote:
No, if you do:
opens assets.textures;
```
you get:
```Error occurred during initialization of boot layer
java.lang.module.FindException: Error reading module: /.../hellofx/build/classes/java/main
Caused by: java.lang.module.InvalidModuleDescriptorException: Package assets.textures not found in module
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#644?email_source=notifications&email_token=AA3NT5VMHS527ODEUCCAXCTP6MP5VA5CNFSM4H62RPMKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZMZIGY#issuecomment-509187099>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AA3NT5U6YJ2T6FCP3CTU7J3P6MP5VANCNFSM4H62RPMA>
.
|
Yes, that works. But I wouldn't do it... |
Fair enough. I’ll see if classloader approach works.
…On Mon, 8 Jul 2019 at 12:29 pm, José Pereda ***@***.***> wrote:
Yes, that works. But I wouldn't do it...
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#644?email_source=notifications&email_token=AA3NT5WCSFI5NY3VRS33SWTP6MQIXA5CNFSM4H62RPMKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZMZOEA#issuecomment-509187856>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AA3NT5UHY5UESJOYDIHFM23P6MQIXANCNFSM4H62RPMA>
.
|
|
Could you do a quick check with |
Sure |
Also fails, I'll see if there is anything on the web related to module API access |
We use that from Gluon Mobile to get access to some configuration files in the user's project (at the root of the resources folder), something like:
|
Configuration.class is Gluon Mobile's class I presume? Ok ... |
Right, I've got something. I've found one approach, I don't know if it's the only one. It appears that to open a resource, it must be placed in the same package that is open to a different module, e.g.: module samples.main {
} So brick.png must be under The problem with this is the unified assets directory architecture is ruined since everything needs to be under their respective packages for this to work |
In any case, were you planning to use fxgl to test Gluon client plugin? Because I haven't yet merged changes that allow compile and run to succeed |
Following that approach, you could always add a dummy class to But still the user has to open it. It should be better to have a solution that doesn't require fixed package names for resources nor opening them from the user's module descriptor. About the Client plugin: No, I wasn't (I noticed this issue while I was checking this question https://stackoverflow.com/questions/56931096/fxgl-noclassdeffounderror-when-calling-fxgl-playdrop-wav) |
I think the pragmatic workaround of declaring the module as |
When the project is modular, since
AssetLoader
is in a different module, it doesn't have access to theassets/sound
orassets/texture
resources folders.which is caused by:
GameApplication.FXGLApplication.app?.javaClass?.getResource(name)
being null, in `AssetLoader::getURL.There are a few options to solve this (using
getClassLoader().getResource()
should do it, and it is the simplest way. Other options involve something more complex likeModuleLayer.boot().findModule(moduleName)...
)The text was updated successfully, but these errors were encountered: