Package playn.java
Class JavaAssets
java.lang.Object
playn.core.Assets
playn.java.JavaAssets
Loads Java assets via the classpath.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDirectory(File dir) Adds the given directory to the search path for resources.getBytesSync(String path) Loads a Java font frompath.Returns the currently configured path prefix.getRemoteImage(String url, int width, int height) getTextSync(String path) voidsetAssetScale(float scaleFactor) Configures the default scale to use for assets.voidsetPathPrefix(String prefix) Configures the prefix prepended to asset paths before fetching them from the classpath.Methods inherited from class playn.core.Assets
getBytes, getImage, getImageSync, getRemoteImage, getText
-
Constructor Details
-
JavaAssets
Creates a new java assets.
-
-
Method Details
-
setPathPrefix
Configures the prefix prepended to asset paths before fetching them from the classpath. For example, if your assets are insrc/main/java/com/mygame/assets(or insrc/main/resources/com/mygame/assets), you can passcom/mygame/assetsto 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.NOTE: the path prefix is not used when searching extra directories
-
getPathPrefix
Returns the currently configured path prefix. Note that this value will always have a trailing slash. -
addDirectory
Adds the given directory to the search path for resources.TODO: remove? get?
-
setAssetScale
public void setAssetScale(float scaleFactor) Configures the default scale to use for assets. This allows one to specify an intermediate graphics scale (like 1.5) and scale the 2x imagery down to 1.5x instead of scaling the 1.5x imagery up (or displaying nothing at all). -
getFont
Loads a Java font frompath. Currently only TrueType (.ttf) fonts are supported.- Parameters:
path- the path to the font resource (relative to the asset manager's path prefix).- Throws:
Exception- if an error occurs loading or decoding the font.
-
getRemoteImage
- Overrides:
getRemoteImagein classAssets
-
getSound
-
getMusic
-
getTextSync
- Specified by:
getTextSyncin classAssets- Throws:
Exception
-
getBytesSync
- Specified by:
getBytesSyncin classAssets- Throws:
Exception
-