<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Allegro 5, Android, loading assets</title>
		<link>http://www.allegro.cc/forums/view/617058</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Mon, 25 Sep 2017 14:52:50 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Hello all,</p><p>I&#39;m trying to port an A5 game I&#39;ve written to Android (previous thread here <a href="https://www.allegro.cc/forums/thread/616695/1027864">https://www.allegro.cc/forums/thread/616695/1027864</a> - I&#39;ve now got a 64 bit Windows machine)</p><p>I&#39;ve followed these instructions: <a href="https://github.com/liballeg/android">https://github.com/liballeg/android</a></p><p>and have code building and running, but it fails to load any assets. I&#39;ve searched a fair bit, but can&#39;t seem to find:</p><p>- Where I need to put the asset files so that they get included in the .apk when I build the project (The project structure has 4 directories called &#39;assets&#39;....)</p><p>- How I tell allegro where to find them. (I guess I need to start with one of the ALLEGRO_xxx_PATH defines, but I don&#39;t know which one. I maybe also need to call al_android_set_apk_file_interface() or possibly al_android_set_apk_fs_interface() but I don&#39;t know which, or when!)</p><p>Can anyone help me with either of these issues?</p><p>Cheers,</p><p>Ian
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Ian Lewis)</author>
		<pubDate>Sat, 23 Sep 2017 19:16:32 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>After you call &quot;al_android_set_apk_file_interface()&quot;, all file related functions from Allegro - <a href="http://liballeg.org/a5docs/trunk/file.html">http://liballeg.org/a5docs/trunk/file.html</a> - are now using &quot;assets&quot; directory from your APK file.</p><p>After you call &quot;al_android_set_apk_fs_interface()&quot;, all filesystem related functions from Allegro - <a href="http://liballeg.org/a5docs/trunk/fshook.html">http://liballeg.org/a5docs/trunk/fshook.html</a> - are now using &quot;assets&quot; directory from your APK file.</p><p>So you call them depending on what you use in your code.</p><p>I don&#39;t know anything about Android Studio, so if I were you I&#39;d just place different stuff into those four &quot;assets&quot; directory and see what gets into the apk file (which you can simply unzip as regular zip file).
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Sebastian Krzyszkowiak)</author>
		<pubDate>Sat, 23 Sep 2017 21:19:53 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Thanks for that. I hadn&#39;t realised I could open the .apk file. I can now see that I have assets in the &#39;assets&#39; folder. </p><p>Sadly, I still can&#39;t figure out how to get allegro to see them. The only function I use from either of those links is</p><p>al_change_directory()</p><p>but (obviously) I use al_load_bitmap(), al_load_sample() etc. a lot. From what you say, they are unaffected by al_android_set_apk_fs_interface(). </p><p>When I use either al_get_current_directory() or al_get_standard_path() I get something like</p><p><i>data/user/0/com.tootiredgames.gravstorm/files</i></p><p>If I peek inside the apk, I see folders called assets (where my assets are) lib, META-INF, res, plus AndroidManifest.xml, and a few more files.</p><p>I can&#39;t see any relationship between the path and the contents of the apk. I&#39;ve tried just appending /assets to the path, but that doesn&#39;t seem to work. </p><p>At the moment, it doesn&#39;t seem to make any difference whether I call al_android_set_apk_fs_interface() or not. al_load_xxx calls always return NULL.</p><p>Anyone know what I should be doing to set the path so that I can load assets?</p><p>Cheers,</p><p>Ian.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Ian Lewis)</author>
		<pubDate>Sat, 23 Sep 2017 23:42:04 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Don&#39;t use al_get_current_directory nor al_get_standard_path. They are irrelevant once you switch to the apk interface. Use the relative paths.</p><p>Functions like al_load_bitmap use the file interface under the hood, so you&#39;re interested mostly in al_android_set_apk_file_interface.</p><p>After you call that, you should be able to just call al_load_bitmap(&quot;my_dir/my_file.png&quot;) to access a file assets/my_dir/my_file.png inside the APK.</p><p>(AFAIK you should also be able to use absolute paths inside the APK in form &quot;/my_dir/my_file.png&quot;. Basically, when using the APK interface, your assets directory becomes the root directory)
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Sebastian Krzyszkowiak)</author>
		<pubDate>Sun, 24 Sep 2017 03:55:30 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Ah, thank you! Assets are now loading, and my game is running!</p><p>Cheers,</p><p>Ian.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Ian Lewis)</author>
		<pubDate>Mon, 25 Sep 2017 14:52:50 +0000</pubDate>
	</item>
</rss>
