public class JavaAssets extends Assets
| Constructor | Description |
|---|---|
JavaAssets(JavaPlatform plat) |
Creates a new java assets.
|
| Modifier and Type | Method | Description |
|---|---|---|
void |
addDirectory(java.io.File dir) |
Adds the given directory to the search path for resources.
|
java.nio.ByteBuffer |
getBytesSync(java.lang.String path) |
|
java.awt.Font |
getFont(java.lang.String path) |
Loads a Java font from
path. |
Sound |
getMusic(java.lang.String path) |
|
java.lang.String |
getPathPrefix() |
Returns the currently configured path prefix.
|
Image |
getRemoteImage(java.lang.String url,
int width,
int height) |
|
Sound |
getSound(java.lang.String path) |
|
java.lang.String |
getTextSync(java.lang.String path) |
|
void |
setAssetScale(float scaleFactor) |
Configures the default scale to use for assets.
|
void |
setPathPrefix(java.lang.String prefix) |
Configures the prefix prepended to asset paths before fetching them from the classpath.
|
getBytes, getImage, getImageSync, getRemoteImage, getTextpublic JavaAssets(JavaPlatform plat)
public void setPathPrefix(java.lang.String prefix)
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.
NOTE: the path prefix is not used when searching extra directories
public java.lang.String getPathPrefix()
public void addDirectory(java.io.File dir)
TODO: remove? get?
public void setAssetScale(float scaleFactor)
public java.awt.Font getFont(java.lang.String path)
throws java.lang.Exception
path. Currently only TrueType (.ttf) fonts are
supported.path - the path to the font resource (relative to the asset manager's path prefix).java.lang.Exception - if an error occurs loading or decoding the font.public Image getRemoteImage(java.lang.String url, int width, int height)
getRemoteImage in class Assetspublic java.lang.String getTextSync(java.lang.String path)
throws java.lang.Exception
getTextSync in class Assetsjava.lang.Exceptionpublic java.nio.ByteBuffer getBytesSync(java.lang.String path)
throws java.lang.Exception
getBytesSync in class Assetsjava.lang.ExceptionCopyright © 2018. All Rights Reserved.