fileResources
In a JVM context, path is the path of a file (which may be a relative path). The textures are loaded immediately (unlike in a JS context, where there will be a delay).
In a JS context, path is the start of a URL which serves the image, with Resources.loadTexture's name
parameter completing the url. e.g. path
might be /resources
and name
is myIcons.png
, and therefore the final url is /resources/myIcons.png
. Not that the server isn't specified, as this is assumed to be the same web server which served the html and .js files.
Given that these resources cannot be retrieved immediately, you may want to use Texture.onLoaded to run code once the image has been loaded. However, in many/most cases this isn't necessary, as a placeholder is returned, and the scene will be updated automatically when/if the image is loaded. In particular, any ImageViews
which directly use the (yet to be loaded) texture will automatically update when the texture is loaded.
Note, no caching is performed, therefore loading the same image twice will load and create two independent textures (a waste of time and memory).