Load resources from outside of asset..?

23 views
Skip to first unread message

Aureulus X

unread,
May 11, 2015, 9:36:45 AM5/11/15
to pl...@googlegroups.com
Hi,

I often want to load resources (images etc.) during the prototyping process with PlayN. Usually these files are outside of my project and I am forced to copy them to assets in order to use them. This is merely for testing purposes and the resources should be removed later.

Am I missing something? Maybe it is possible (especially when only prototyping in Java) to load some resources from outside? Directly via a path from my file system?

Unrelated: I just read something in the forum about clipboard support? Is it already in Playn2.0?

Auri

Michael Bayne

unread,
Jun 22, 2015, 12:38:28 PM6/22/15
to pl...@googlegroups.com
On Mon, May 11, 2015 at 6:36 AM, Aureulus X <aureolus.vo...@googlemail.com> wrote:
I often want to load resources (images etc.) during the prototyping process with PlayN. Usually these files are outside of my project and I am forced to copy them to assets in order to use them. This is merely for testing purposes and the resources should be removed later.

Am I missing something? Maybe it is possible (especially when only prototyping in Java) to load some resources from outside? Directly via a path from my file system?

Yes, use JavaAssets.addDirectory(). For example:

public class HelloGameJava {
  public static void main(String[] args) {
    LWJGLPlatform plat = new LWJGLPlatform(new LWJGLPlatform.Config());

    File home = new File(System.getProperty("user.dir"));
    File tempAssets = new File(home, "tempAssets");
    plat.assets().addDirectory(tempAssets);

    new HelloGame(plat);
    plat.start();
  }
}

Then, in your game, when you request, for example:

plat.assets().getImage("test.png")

it will first search the standard location, and then look for $HOME/tempAssets/test.png.

Unrelated: I just read something in the forum about clipboard support? Is it already in Playn2.0?
Reply all
Reply to author
Forward
0 new messages