|
I can't get my Android game to load assets |
olddog
Member #20,687
August 2021
|
Hello, al_android_set_apk_file_interface(); In the beginning of main() right after al_init. However, PHYSFS_init(argv_0); font = al_load_font("myfont.ttf",12,0); Returns null. Any help greatly appreciated. |
Elias
Member #358
May 2000
|
Does it work without physfs? -- |
olddog
Member #20,687
August 2021
|
yes, it appears I can load non zip files (not sure about .dat files), but I can load fonts, bitmaps etc. Once I call the physfs functions, it can't access any file (or at least not the files I requested). I am thinking to just unpack all the data files into the asset directory and reference the files directly instead of trying to figure out physfs. |
Elias
Member #358
May 2000
|
It's a bit weird since the .apk itself is a .zip file. So to read a .zip file inside of /assets in a way you'd need to chain al_android_set_apk_file_interface (to read the .zip inside of /assets in the .apk) with physfs (to read within the .zip). I never tried but I think we don't support chaining of file interfaces so this probably does not work. (It sounds like chaining is a useful feature though, so maybe we should add support for it.) Another way to get it to work would be to point physfs to the .apk file. Then it can just read it as a .zip (and then a .zip inside that .zip, assuming that's supported by physfs). However I'm not sure if Android allows you to find your own .apk, but it probably does. So once you have the APK path you can instruct physfs to read from it (and you won't need al_android_set_apk_file_interface at all). The way I'm using is like you said - I just copy my "data" folder into "assets" then access it with al_android_set_apk_file_interface() which will read from there. -- |
olddog
Member #20,687
August 2021
|
Thank you for the helpful information. I will try it out, but I am ok with just copying everything into the assets directory and accessing files directly. |
|