playn.java
Class JavaAssets

java.lang.Object
  extended by playn.core.AbstractAssets
      extended by playn.java.JavaAssets
All Implemented Interfaces:
Assets

public class JavaAssets
extends AbstractAssets

Loads Java assets via the classpath.


Constructor Summary
JavaAssets()
           
 
Method Summary
protected  Image doGetImage(String path)
           
protected  Sound doGetSound(String path)
           
protected  void doGetText(String path, ResourceCallback<String> callback)
           
 String getPathPrefix()
          Returns the currently configured path prefix.
protected  URL requireResource(String path)
           
 void setPathPrefix(String prefix)
          Configures the prefix prepended to asset paths before fetching them from the classpath.
 
Methods inherited from class playn.core.AbstractAssets
getImage, getPendingRequestCount, getSound, getText, isDone
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JavaAssets

public JavaAssets()
Method Detail

setPathPrefix

public void setPathPrefix(String prefix)
Configures the prefix prepended to asset paths before fetching them from the classpath. For example, if your assets are in src/main/java/com/mygame/assets (or in src/main/resources/com/mygame/assets), you can pass com/mygame/assets to this method and then load your assets without prefixing their path with that value every time. The value supplied to this method should not contain leading or trailing slashes. Note that this prefix should always use '/' as a path separator as it is used to construct URLs, not filesystem paths.


getPathPrefix

public String getPathPrefix()
Returns the currently configured path prefix. Note that this value will always have a trailing slash.


doGetImage

protected Image doGetImage(String path)
Specified by:
doGetImage in class AbstractAssets

doGetSound

protected Sound doGetSound(String path)
Specified by:
doGetSound in class AbstractAssets

doGetText

protected void doGetText(String path,
                         ResourceCallback<String> callback)
Specified by:
doGetText in class AbstractAssets

requireResource

protected URL requireResource(String path)
                       throws FileNotFoundException
Throws:
FileNotFoundException


Copyright © 2012. All Rights Reserved.