Class WSprite
java.lang.Object
io.github.cottonmc.cotton.gui.widget.WWidget
io.github.cottonmc.cotton.gui.widget.WSprite
- Direct Known Subclasses:
WTiledSprite
-
Field Summary
Modifier and TypeFieldDescriptionprotected int
protected long
protected Texture[]
protected int
protected long
protected boolean
protected int
-
Constructor Summary
ConstructorDescriptionCreate a new animated sprite.WSprite
(int frameTime, Identifier... frames) Create a new animated sprite.Create a new sprite with a single image.WSprite
(Identifier image) Create a new sprite with a single image.WSprite
(Identifier image, float u1, float v1, float u2, float v2) Create a new sprite with a single image and custom UV values. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Checks whether this widget can be resized usingWWidget.setSize(int, int)
.void
paint
(DrawContext context, int x, int y, int mouseX, int mouseY) Paints this widget.protected void
paintFrame
(DrawContext context, int x, int y, Texture texture) Paints a single frame for this sprite.Sets the animation frames of this sprite.setFrames
(Identifier... frames) Sets the animation frames of this sprite.Sets the image of this sprite.setImage
(Identifier image) Sets the image of this sprite.setOpaqueTint
(int tint) Sets the tint for this sprite to the following opaque color.setTint
(int tint) Sets the tint for this sprite to the following color-with-alpha.setUv
(float u1, float v1, float u2, float v2) Sets the UV values of this sprite.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
-
Field Details
-
currentFrame
protected int currentFrame -
currentFrameTime
protected long currentFrameTime -
frames
-
frameTime
protected int frameTime -
lastFrame
protected long lastFrame -
singleImage
protected boolean singleImage -
tint
protected int tint
-
-
Constructor Details
-
WSprite
Create a new sprite with a single image.- Parameters:
texture
- The image texture to display.- Since:
- 3.0.0
-
WSprite
Create a new sprite with a single image.- Parameters:
image
- The location of the image to display.
-
WSprite
Create a new sprite with a single image and custom UV values.- Parameters:
image
- The location of the image to display.u1
- the left edge of the texturev1
- the top edge of the textureu2
- the right edge of the texturev2
- the bottom edge of the texture
-
WSprite
Create a new animated sprite.- Parameters:
frameTime
- How long in milliseconds to display for. (1 tick = 50 ms)frames
- The locations of the frames of the animation.
-
WSprite
Create a new animated sprite.- Parameters:
frameTime
- 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
-
setImage
Sets the image of this sprite.- Parameters:
image
- the new image- Returns:
- this sprite
-
setFrames
Sets the animation frames of this sprite.- Parameters:
frames
- the frames- Returns:
- this sprite
-
setImage
Sets the image of this sprite.- Parameters:
image
- the new image- Returns:
- this sprite
- Since:
- 3.0.0
-
setFrames
Sets the animation frames of this sprite.- Parameters:
frames
- the frames- Returns:
- this sprite
- Since:
- 3.0.0
-
setTint
Sets the tint for this sprite to the following color-with-alpha. If you don't want to specify alpha, usesetOpaqueTint(int)
instead.- Parameters:
tint
- the new tint- Returns:
- this sprite
-
setOpaqueTint
Sets the tint for this sprite to the following opaque color.- Parameters:
tint
- the new tint- Returns:
- this sprite
-
setUv
Sets the UV values of this sprite.- Parameters:
u1
- the left edge of the texturev1
- the top edge of the textureu2
- the right edge of the texturev2
- the bottom edge of the texture- Returns:
- this sprite
- Since:
- 1.8.0
-
canResize
public boolean canResize()Description copied from class:WWidget
Checks whether this widget can be resized usingWWidget.setSize(int, int)
. -
paint
Description copied from class:WWidget
Paints this widget. -
paintFrame
Paints a single frame for this sprite.- Parameters:
context
- the draw contextx
- the X coordinate to draw it aty
- the Y coordinate to draw it attexture
- the texture to draw
-