Interface TextureRegistry
-
public interface TextureRegistry
The interface for a texture registry used by aGameWindow
.- Author:
- Tim Neumann
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
addAnimationFrameToTexture(String animatedTexture, String frameTexture, long frames)
Add a animation frame to an animated texture.String
createAnimatedTexture(boolean loop)
Create a new animated texture with the animation length in render ticks.boolean
isTextureAnimated(String textureHandle)
Check if a texture is animated.String
loadTextureFromFile(String filePath)
Load an image from a file path as texture and return the handle to the texture.String
loadTextureFromResource(String resourceName, Function<String,InputStream> resourceProvider)
Load an image from an internal resource as texture and return the handle to the texture.
-
-
-
Method Detail
-
loadTextureFromResource
String loadTextureFromResource(String resourceName, Function<String,InputStream> resourceProvider)
Load an image from an internal resource as texture and return the handle to the texture.The image will only be loaded once and subsequent loads only return the existing texture handle.
- Parameters:
resourceName
- the name of the texture resourceresourceProvider
- a function providing the input stream for the resource with the name, given to it as the parameter.A typical implementation is
<name of class>.class::getResourceAsStream
- Returns:
- the handle to retrieve the texture
- Throws:
TextureNotFoundException
- the texture could not be loaded from the given resource location
-
createAnimatedTexture
String createAnimatedTexture(boolean loop)
Create a new animated texture with the animation length in render ticks. UseaddAnimationFrameToTexture(java.lang.String, java.lang.String, long)
to add animation frames to the animated texture.- Parameters:
loop
- if true the animation will loop after the last frame- Returns:
- the handle to retrieve the texture
-
addAnimationFrameToTexture
void addAnimationFrameToTexture(String animatedTexture, String frameTexture, long frames)
Add a animation frame to an animated texture.- Parameters:
animatedTexture
- the animated texture to add the animation frame toframeTexture
- the texture to add as animation frameframes
- the number of frames to show this texture
-
isTextureAnimated
boolean isTextureAnimated(String textureHandle)
Check if a texture is animated.- Parameters:
textureHandle
- the texture to check- Returns:
- true iff the texture is animated
-
loadTextureFromFile
String loadTextureFromFile(String filePath)
Load an image from a file path as texture and return the handle to the texture. The image will only be loaded once and subsequent loads only return the existing texture handle.- Parameters:
filePath
- the path to the texture image file- Returns:
- the handle to retrieve the texture
- Throws:
TextureNotFoundException
- the texture could not be loaded from the given file path
-
-