About Store Forum Documentation Contact



Post Reply 
[Android] Copy assets to the device
Author Message
Kevin Offline
Member

Post: #1
[Android] Copy assets to the device
Hi,

I am currently a bit unsure about how EE copies the assets (stuff in the Data folder) to the device.
I created a very simple world and wrote a esenthel script which shows the world. This works fine on Windows, but on android I get errors about assets which can't be found.
Code:
Game.ObjMemx<Game.Static> Statics;
Game.ObjMemx<Game.Chr> Chrs;

// Called before the device is initialized
void InitPre()
{
   App.name("SciFi Tower Defense");
  
   // Set app flags for mobile development
#ifdef _ANDROID
   App.flag = APP_AUTO_FREE_OPEN_GL_ES_DATA | APP_AUTO_FREE_PHYS_BODY_HELPER_DATA | APP_AUTO_PARTICLES_CONVERT_BLEND;
#endif
  
   // Set paths for windows and mobile platforms
#ifdef _ANDROID
   DataPath("../../../../Data/");
#else // Windows
   DataPath("../../Data/");
#endif
  
   // Add the engine pak which contains all the engine related assets
   Paks.add("engine.pak");
}

bool Init()
{
   Physics.create(CSS_MATERIALS, true, "C:/Program Files (x86)/Esenthel Engine/EsenthelEngineSDK/Installation/PhysX");
  
   Sky.atmospheric();
   Sun.image = "Env/Sky/sun.gfx";
   Clouds.layered.set(2, Images("Env/Cloud/0.gfx"));
  
   Game.World.init();
  
   Game.World.setObjType(Statics, Game.ObjType("OBJ_STATIC"));
   Game.World.setObjType(Chrs, Game.ObjType("OBJ_CHR"));
  
   Game.World.New("World/test.world");
  
  
   return true;  
}

void Shut()
{
  
}

bool Update()
{  
#ifdef _ANDROID  
   FREPA(Touches)
   {
      return false;
   }
#endif

   Clouds.layered.update();
  
  
   Cam.setSpherical(Vec(0, 0, 0), PI_4, -PI_6, 0, 20).updateVelocities().set();
   Game.World.update(Cam.matrix.pos);
  
   return true;  
}

void Render()
{
   Game.World.draw();
}

void Draw()
{
  
   Renderer(Render);
  
   D.text(0, 0.9, S+"Fps:"+Time.fps());  
}

When I run the application I get the error
Can't load "Env/Sky/sun.gfx"

If I uncomment some of the lines where I load those assets I get errors that other assets can't be loaded:
Can't load "Env/Cloud/0.gfx"
Can't load "World/test.world"


So, are those assets copied to the device automatically or do I have to do anything manually?
Also what about Physics, is do I have to specify a path to the installation folder when I am on an android device?
07-05-2012 02:59 PM
Find all posts by this user Quote this message in a reply
Kevin Offline
Member

Post: #2
RE: [Android] Copy assets to the device
Okay, I figured it out.

The assets have to be in the asset folder, but after building in Coder Editor it isn't copied automatically. So the solution was to pack all the assets into a .pak file and add a Resource folder to the Application (in Code Editor), where you add the .pak file.

The android example project shows that quite well.

But I would suggest to also add some information on this to the wiki wink
07-05-2012 08:22 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #3
RE: [Android] Copy assets to the device
Yes creating PAK's and including them in the project view is the way to go.
for Physics on android the path is completely ignored as there are no DLL's on android.
I am working on a solution that does automatic asset packaging when building the apps, but it will take some time.
07-05-2012 08:43 PM
Find all posts by this user Quote this message in a reply
cmontiel Offline
Member

Post: #4
RE: [Android] Copy assets to the device
Code:
I am working on a solution that does automatic asset packaging when building the apps, but it will take some time.

That would be great. It will save a lot of time.grin

IRC: irc.freenode.net
Channel: #Esenthel
07-05-2012 09:04 PM
Find all posts by this user Quote this message in a reply
Post Reply