Hello. I'm having issues with finding paths in an Android project of mine. Here's my path-setting function:
void SetResourcePath(const char *k_resources_directory) { ALLEGRO_PATH *path = al_get_standard_path(ALLEGRO_RESOURCES_PATH); al_append_path_component(path, k_resources_directory); al_change_directory(al_path_cstr(path, '/')); al_destroy_path(); }
The directory of my resources is ./assets, which I call by SetResourcePath("assets"). Well, it's not working on Android. Is there any particular reason as to why this is?
Also, I can't seem to get my Android project to compile with my own directories. For example, I want to have a "potatoes" directory, so I throw the directory into the project, but it doesn't compile with it. It does, however, compile with an "assets" directory. Why is that?
Yeah, its been a while since i last played with those things, but I'm not sure you can get to the actual app resources with ALLEGRO_RESOURCES_PATH. Try ALLEGRO_USER_DATA_PATH.
Also, I can't seem to get my Android project to compile with my own directories. For example, I want to have a "potatoes" directory, so I throw the directory into the project, but it doesn't compile with it. It does, however, compile with an "assets" directory. Why is that?
I think its because Android has a specific package layout that you need to stick to.
Edit (13.09.06 at 13:43 PST)
I believe I've found a solution, but have met yet another obstacle. Please view this forum post.
Edit (13.09.06 at 16:00 PST)
In Ubuntu, the sources can be procured just fine, but when thrown onto Android in an APK, it can't seem to find the assets directory. Below is some code I threw together quite quickly to swift through the file-path options and to stop upon finally procuring the image file. It always lands on ALLEGRO_RESOURCES_PATH when in Ubuntu, but never finds it at all when in an APK. Thoughts? :o
<code name="LoadResources">
// ===========================================================================
// Procure and initate game-related resources and objects
// ===========================================================================
void Thaed::LoadResources(void) {
while (true) {
static int s_i = 0;
// Attempt to procure the file in question
b = al_load_bitmap("player.png");
if (!b) {
// Cycle through the next path phase if bitmap wasn't procured
BombuSetResourceDirectory(s_i, "assets");
}
else break; // Bitmap was procured, so end the loop
cout << "Checking " << s_i << "...\n";
++s_i;
if (s_i > 5) break; // We're only checking six paths
}
}
</code>
<code name="BombuSetResourceDirectory">
// ===========================================================================
// Redirect the current working directory to the resource directory
// ===========================================================================
void Bombu::BombuSetResourceDirectory(const int k_what, const char *k_directory) {
ALLEGRO_PATH *path;
switch (k_what) {
case 0: path = al_get_standard_path(ALLEGRO_USER_HOME_PATH); break;
case 1: path = al_get_standard_path(ALLEGRO_USER_SETTINGS_PATH); break;
case 2: path = al_get_standard_path(ALLEGRO_USER_DOCUMENTS_PATH); break;
case 3: path = al_get_standard_path(ALLEGRO_RESOURCES_PATH); break;
case 4: path = al_get_standard_path(ALLEGRO_EXENAME_PATH); break;
case 5: path = al_get_standard_path(ALLEGRO_USER_DATA_PATH); break;
default: path = al_get_standard_path(ALLEGRO_USER_HOME_PATH); break;
}
// Reroute the current working directory
al_append_path_component(path, k_directory);
al_change_directory(al_path_cstr(path, '/'));
cout << al_path_cstr(path, '/') << endl;
// Remove path from memory now that the directories are in working order
al_destroy_path(path);
}
</code>