Class WTiledSprite
java.lang.Object
io.github.cottonmc.cotton.gui.widget.WWidget
io.github.cottonmc.cotton.gui.widget.WSprite
io.github.cottonmc.cotton.gui.widget.WTiledSprite
A sprite whose texture will be tiled.
- Since:
- 2.0.0
-
Field Summary
Fields inherited from class io.github.cottonmc.cotton.gui.widget.WSprite
currentFrame, currentFrameTime, frames, frameTime, lastFrame, singleImage, tint
-
Constructor Summary
ConstructorDescriptionWTiledSprite
(int tileWidth, int tileHeight, int frameTime, Texture... frames) Create a new animated tiled sprite.WTiledSprite
(int tileWidth, int tileHeight, int frameTime, Identifier... frames) Create a new animated tiled sprite.WTiledSprite
(int tileWidth, int tileHeight, Texture image) Create a tiled sprite.WTiledSprite
(int tileWidth, int tileHeight, Identifier image) Create a tiled sprite. -
Method Summary
Modifier and TypeMethodDescriptionint
Gets the tile height of this sprite.int
Gets the tile width of this sprite.void
paintFrame
(DrawContext context, int x, int y, Texture texture) Paints a single frame for this sprite.setTileHeight
(int tileHeight) Sets the tile height of this sprite.void
setTileSize
(int width, int height) Sets the tiling size.setTileWidth
(int tileWidth) Sets the tile width of this sprite.Methods inherited from class io.github.cottonmc.cotton.gui.widget.WSprite
canResize, paint, setFrames, setFrames, setImage, setImage, setOpaqueTint, setTint, setUv
Methods inherited from class io.github.cottonmc.cotton.gui.widget.WWidget
addNarrations, addPainters, addTooltip, canFocus, canHover, getAbsoluteX, getAbsoluteY, getFocusModel, getHeight, getHost, getParent, getWidth, getX, getY, hit, hoveredProperty, isActivationKey, isFocused, isHovered, isNarratable, isWithinBounds, onCharTyped, onClick, onFocusGained, onFocusLost, onHidden, onKeyPressed, onKeyReleased, onMouseDown, onMouseDrag, onMouseMove, onMouseScroll, onMouseUp, onShown, releaseFocus, renderTooltip, requestFocus, setHost, setHovered, setLocation, setParent, setSize, shouldRenderInDarkMode, tick, validate
-
Constructor Details
-
WTiledSprite
Create a tiled sprite.- Parameters:
tileWidth
- The width a tiletileHeight
- The height of a tileimage
- The image to tile
-
WTiledSprite
Create a new animated tiled sprite.- Parameters:
tileWidth
- The width a tiletileHeight
- The height of a tileframeTime
- How long in milliseconds to display for. (1 tick = 50 ms)frames
- The locations of the frames of the animation.
-
WTiledSprite
Create a tiled sprite.- Parameters:
tileWidth
- The width a tiletileHeight
- The height of a tileimage
- The image to tile- Since:
- 3.0.0
-
WTiledSprite
Create a new animated tiled sprite.- Parameters:
tileWidth
- The width a tiletileHeight
- The height of a tileframeTime
- How long in milliseconds to display for. (1 tick = 50 ms)frames
- The locations of the frames of the animation.- Since:
- 3.0.0
-
-
Method Details
-
setTileSize
public void setTileSize(int width, int height) Sets the tiling size. This determines how often the texture will repeat.- Parameters:
width
- the new tiling widthheight
- the new tiling height
-
getTileWidth
public int getTileWidth()Gets the tile width of this sprite.- Returns:
- the tile width
- Since:
- 2.2.0
-
getTileHeight
public int getTileHeight()Gets the tile height of this sprite.- Returns:
- the tile height
- Since:
- 2.2.0
-
setTileWidth
Sets the tile width of this sprite.- Parameters:
tileWidth
- the new tile width- Returns:
- this sprite
- Since:
- 2.2.0
-
setTileHeight
Sets the tile height of this sprite.- Parameters:
tileHeight
- the new tile height- Returns:
- this sprite
- Since:
- 2.2.0
-
paintFrame
Description copied from class:WSprite
Paints a single frame for this sprite.- Overrides:
paintFrame
in classWSprite
- Parameters:
context
- the draw contextx
- the X coordinate to draw it aty
- the Y coordinate to draw it attexture
- the texture to draw
-