Package squidpony.squidgrid.gui.gdx
Class SparseLayers
java.lang.Object
com.badlogic.gdx.scenes.scene2d.Actor
squidpony.squidgrid.gui.gdx.SparseLayers
- All Implemented Interfaces:
IPackedColorPanel
- Direct Known Subclasses:
SquidMessageBox
,SubcellLayers
public class SparseLayers extends com.badlogic.gdx.scenes.scene2d.Actor implements IPackedColorPanel
A general-purpose char display grid that supports one layer of backgrounds and arbitrarily many layers of foreground,
only rendering foreground chars when something is present at a char's location. This also stores an ArrayList of
The names are a little different for some member fields here; there's a
Created by Tommy Ettinger on 7/28/2017.
TextCellFactory.Glyph
items that can be added to using glyph(char, Color, int, int)
or one of
several other methods; these Glyphs can have effects performed on them that are analogous to the effects on
SquidPanel
's AnimatedEntity
effects, such as
slide(TextCellFactory.Glyph, int, int, int, int, float, Runnable)
. Unlike SquidPanel and SquidLayers, this
class does not typically provide many overloads for each method, and usually limits the overloads to one that takes
a packed float color and one that takes a libGDX Color
, and all the other parameters are expected to be
specified explicitly rather than relying on default behavior. SparseLayers tends to perform better than SquidLayers,
especially when a lot of the map is unassigned/blank. It will cause less GC pressure when packed floats are used, and
because SColor
constants pre-calculate their packed float values, using the overloads that take a Color will
perform a little better when given an SColor than a plain libGDX Color. This class makes heavy use of
SColor.lerpFloatColors(float, float, float)
because it should cause no GC pressure (it doesn't create
temporary Color objects), and if you don't want to mutate Colors in-place (which is a bad idea for constants), then
using lerpFloatColors with the packed float color API here should be very effective.
The names are a little different for some member fields here; there's a
TextCellFactory
called font
,
a float[][]
called backgrounds
that stores packed float colors, an ArrayList of
SparseTextMap
that implements the sparse drawing behavior of foreground chars called layers
, and so
on.
Created by Tommy Ettinger on 7/28/2017.
-
Field Summary
Fields Modifier and Type Field Description int
animationCount
Deprecated.UsehasActiveAnimations()
instead of adjusting this manuallyfloat[][]
backgrounds
A 2D float array of background colors as packed floats.com.badlogic.gdx.graphics.Color
defaultBackground
The default foreground color when none is specified, as a Color object.com.badlogic.gdx.graphics.Color
defaultForeground
The default foreground color when none is specified, as a Color object.float
defaultPackedBackground
The value ofdefaultForeground
as a float, for easier usage with the methods that use floats for colors.float
defaultPackedForeground
The value ofdefaultForeground
as a float, for easier usage with the methods that use floats for colors.TextCellFactory
font
The TextCellFactory that is used to determine font size as well as cell size; must be initialized, usually usingTextCellFactory.initBySize()
, if this is changed after construction.ArrayList<TextCellFactory.Glyph>
glyphs
A list of individually-movable Glyph objects.int
gridHeight
int
gridWidth
ArrayList<SparseTextMap>
layers
A list of SparseTextMap objects, with each representing a foreground layer.protected com.badlogic.gdx.utils.IntIntMap
mapping
IColorCenter<com.badlogic.gdx.graphics.Color>
scc
An IColorCenter to affect color caching and filtering; usually a SquidColorCenter, which can be easily obtained viaDefaultResources.getSCC()
. -
Constructor Summary
Constructors Modifier Constructor Description protected
SparseLayers()
SparseLayers(int gridWidth, int gridHeight)
SparseLayers(int gridWidth, int gridHeight, float cellWidth, float cellHeight)
SparseLayers(int gridWidth, int gridHeight, float cellWidth, float cellHeight, TextCellFactory font)
SparseLayers(int gridWidth, int gridHeight, float cellWidth, float cellHeight, TextCellFactory font, float xOffset, float yOffset)
-
Method Summary
Modifier and Type Method Description SparseTextMap
addLayer()
Adds a layer as a SparseTextMap to this SparseLayers and returns the one just added.SparseTextMap
addLayer(int association)
Adds a layer as a SparseTextMap to this SparseLayers and returns the one just added, or returns an existing layer if one is already associated with the given number.void
blend(int x, int y, float color, float mixBy)
Using the existing background color at the position x,y, this performs color blending from that existing color to the given color (as a float), using the mixBy parameter to determine how much of the color parameter to use (1f will set the color in this to the parameter, while 0f for mixBy will ignore the color parameter entirely).void
bump(float delay, TextCellFactory.Glyph glyph, Direction direction, float duration, Runnable postRunnable)
Start a bumping animation in the given direction after delay seconds, that will last duration seconds; runs postRunnable after the duration completes if postRunnable is non-null.void
bump(TextCellFactory.Glyph glyph, Direction direction, float duration)
Start a bumping animation in the given direction that will last duration seconds.void
burst(float delay, int x, int y, int distance, Radius measurement, char shown, float startColor, float endColor, float duration, Runnable postRunnable)
Convenience method to produce an explosion, splash, or burst effect.void
burst(float delay, int x, int y, int distance, Radius measurement, CharSequence choices, float startColor, float endColor, float duration, Runnable postRunnable)
Convenience method to produce an explosion, splash, or burst effect.void
burst(int x, int y, int distance, Radius measurement, char shown, float startColor, float endColor, float duration)
Convenience method to produce an explosion, splash, or burst effect.void
burst(int x, int y, int distance, Radius measurement, CharSequence choices, float startColor, float endColor, float duration)
Convenience method to produce an explosion, splash, or burst effect.float
calculateConsistentLightAmount(float lightAmount, float modifier)
Allows you to reproduce the effects ofputWithConsistentLight(int, int, char, float, float, float, double, float)
without recalculating the modifier many times per frame.float
calculateConsistentLightModifier()
Gets a modifier that should be given tocalculateConsistentLightAmount(float, float)
; this only needs to be called at most once per frame.float
calculateConsistentLightModifier(float flickerSpeed)
Gets a modifier that should be given tocalculateConsistentLightAmount(float, float)
; this only needs to be called at most once per frame.int
cellHeight()
int
cellWidth()
void
clear()
Removes all background colors, setting them to transparent, and all foreground chars in all layers.void
clear(int layer)
Removes all foreground chars in the requested layer; does not affect the background or other layers.void
clear(int x, int y)
Removes the foreground chars, where present, in all layers at the given x,y position.void
clear(int x, int y, int layer)
Removes the foreground char, if present, in the given layer at the given x,y position.void
draw(com.badlogic.gdx.graphics.g2d.Batch batch, float parentAlpha)
Draws the SparseLayers and all glyphs it tracks.void
fillArea(float color, int x, int y, int width, int height)
Changes the background color in an area to all have the given color, as a packed float.void
fillArea(com.badlogic.gdx.graphics.Color color, int x, int y, int width, int height)
Changes the background color in an area to all have the given color, as a libGDX Color (or SColor, etc.).void
fillBackground(float color)
Fills all of the background with the given color as a packed float.void
fillBackground(com.badlogic.gdx.graphics.Color color)
Fills all of the background with the given color as libGDX Color object.int
findLayer(SparseTextMap layerMap)
Finds the layer number associated with layerMap, or -1 if the given SparseTextMap is not in this SparseLayers.float[][]
getBackgrounds()
Gets a direct reference to the 2D float array this uses for background colors.IColorCenter<com.badlogic.gdx.graphics.Color>
getColorCenter()
Gets the IColorCenter this can use to filter Color objects; this is usually aSquidColorCenter
.com.badlogic.gdx.graphics.Color
getDefaultBackgroundColor()
com.badlogic.gdx.graphics.Color
getDefaultForegroundColor()
TextCellFactory
getFont()
Gets a direct reference to the TextCellFactory this uses to draw and size its text items and cells.int
getGridHeight()
The same asgridHeight()
; here for compatibility with SquidPanel.int
getGridWidth()
The same asgridWidth()
; here for compatibility with SquidPanel.SparseTextMap
getLayer(int layer)
Gets the layer, as a SparseTextMap, that is associated with the given int.int
getLayerCount()
Gets the number of layers currently used in this SparseLayers; if a layer is put into that is equal to or greater than this layer count, then a new layer is created to hold the latest placement.IColorCenter<com.badlogic.gdx.graphics.Color>
getScc()
Gets the IColorCenter for Color objects (almost always a SquidColorCenter, but this isn't guaranteed) that this uses to cache and possibly alter Colors that given to it as parameters.TextCellFactory.Glyph
glyph(char shown, float color, int x, int y)
Produces a single char with a color, that can be positioned independently of the contents of this SparseLayers.TextCellFactory.Glyph
glyph(char shown, com.badlogic.gdx.graphics.Color color, int x, int y)
Produces a single char with a color, that can be positioned independently of the contents of this SparseLayers.TextCellFactory.Glyph
glyphFromGrid(int x, int y)
"Promotes" a colorful char in the first layer to a Glyph that can be positioned independently of the contents of this SparseLayers.TextCellFactory.Glyph
glyphFromGrid(int x, int y, int layer)
"Promotes" a colorful char in the given layer to a Glyph that can be positioned independently of the contents of this SparseLayers.int
gridHeight()
int
gridWidth()
int
gridX(float worldX)
Used internally to go between world positions and grid positions.int
gridY(float worldY)
Used internally to go between world positions and grid positions.boolean
hasActiveAnimations()
Gets whether any animations or other scene2d Actions are running on this SparseLayers.void
put(char[][] chars, float[][] colors)
Places the given char 2D array, if-non-null, in the default foreground color starting at x=0, y=0, while also setting the background colors to match the given 2D array of colors as packed floats.void
put(char[][] chars, float[][] fgColors, float[][] bgColors)
Places the given char 2D array, if-non-null, with the given foreground colors in the first float 2D array, starting at x=0, y=0, while also setting the background colors to match the second float 2D array.void
put(char[][] chars, com.badlogic.gdx.graphics.Color[][] colors)
Places the given char 2D array, if-non-null, in the default foreground color starting at x=0, y=0, while also setting the background colors to match the given Color 2D array.void
put(char[][] chars, com.badlogic.gdx.graphics.Color[][] fgColors, com.badlogic.gdx.graphics.Color[][] bgColors)
Places the given char 2D array, if-non-null, with the given foreground colors in the first Color 2D array, starting at x=0, y=0, while also setting the background colors to match the second Color 2D array.void
put(float[][] colors)
Sets the background colors to match the given 2D array of colors as packed floats.void
put(int x, int y, char c)
Puts the characterc
at(x, y)
with the default foreground.void
put(int x, int y, char c, float foreground)
Puts the char c at the position x,y with the given foreground color as an encoded float (the kind produced byColor.toFloatBits()
).void
put(int x, int y, char c, float foreground, float background)
Puts the char c at the position x,y with the given foreground and background colors as encoded floats, such as those produced byColor.toFloatBits()
.void
put(int x, int y, char c, float foreground, float background, int layer)
Puts the char c at the position x,y in the requested layer with the given foreground and background colors as encoded floats, such as those produced byColor.toFloatBits()
.void
put(int x, int y, char c, com.badlogic.gdx.graphics.Color color)
Puts the characterc
at(x, y)
with somecolor
.void
put(int x, int y, char c, com.badlogic.gdx.graphics.Color foreground, com.badlogic.gdx.graphics.Color background)
Puts the char c at the position x,y with the given foreground and background colors.void
put(int x, int y, char c, com.badlogic.gdx.graphics.Color foreground, com.badlogic.gdx.graphics.Color background, int layer)
Puts the char c at the position x,y in the requested layer with the given foreground and background colors.void
put(int x, int y, float color)
Changes the background at position x,y to the given color as an encoded float.void
put(int x, int y, com.badlogic.gdx.graphics.Color color)
Changes the background at position x,y to the given Color.void
put(int x, int y, String text, float foreground, float background)
Puts text at the position x,y with the given foreground and background colors as encoded floats, such as those produced byColor.toFloatBits()
.void
put(int x, int y, String text, float foreground, float background, int layer)
Puts text at the position x,y in the requested layer with the given foreground and background colors as encoded floats, such as those produced byColor.toFloatBits()
.void
put(int xOffset, int yOffset, String string, com.badlogic.gdx.graphics.Color foreground)
Puts the given string horizontally with the first character at the given offset.void
put(int x, int y, String text, com.badlogic.gdx.graphics.Color foreground, com.badlogic.gdx.graphics.Color background)
Puts text at the position x,y with the given foreground and background colors.void
put(int x, int y, String text, com.badlogic.gdx.graphics.Color foreground, com.badlogic.gdx.graphics.Color background, int layer)
Puts text at the position x,y in the requested layer with the given foreground and background colors.void
put(int xOffset, int yOffset, IColoredString<? extends com.badlogic.gdx.graphics.Color> cs)
Puts the given string horizontally with the first character at the given offset, using the colors thatcs
provides.void
put(int x, int y, ICellVisible cell)
Puts the ICellVisible cell at the position x,y; does not change the background.void
put(int x, int y, ICellVisible cell, float background)
Puts the ICellVisible cell at the position x,y with the given background color as an encoded float, such as those produced byColor.toFloatBits()
.void
put(com.badlogic.gdx.graphics.Color[][] colors)
Sets the background colors to match the given Color 2D array.void
putBorders(float color, String caption)
void
putBordersCaptioned(float color, IColoredString<com.badlogic.gdx.graphics.Color> caption)
void
putChars(char[][] chars)
Places the given char 2D array, if-non-null, in the default foreground color starting at x=0, y=0.void
putChars(char[][] chars, float[][] foregrounds)
Places the given char 2D array, if-non-null, in the foreground starting at x=0, y=0.void
putChars(char[][] chars, com.badlogic.gdx.graphics.Color[][] foregrounds)
Places the given char 2D array, if-non-null, in the foreground starting at x=0, y=0.void
putWithConsistentLight(int x, int y, char c, float foreground, float background, float lightColor, double lightAmount)
A convenience method that handles blending the background color with a specified light color, by a specific amount, without putting a char on the screen; as a whole this affects one x,y position.void
putWithConsistentLight(int x, int y, char c, float foreground, float background, float lightColor, double lightAmount, float flickerSpeed)
A convenience method that handles blending the background color with a specified light color, by a specific amount, without putting a char on the screen; as a whole this affects one x,y position.void
putWithConsistentLight(int x, int y, char c, float foreground, float background, float lightColor, float lightAmount)
A convenience method that handles blending the background color with a specified light color, by a specific amount, without putting a char on the screen; as a whole this affects one x,y position.void
putWithConsistentLight(int x, int y, char c, com.badlogic.gdx.graphics.Color foreground, com.badlogic.gdx.graphics.Color background, com.badlogic.gdx.graphics.Color lightColor, float lightAmount)
A convenience method that handles blending the background color with a specified light color, by a specific amount, without putting a char on the screen; as a whole this affects one x,y position.void
putWithConsistentLight(int x, int y, char c, com.badlogic.gdx.graphics.Color foreground, com.badlogic.gdx.graphics.Color background, com.badlogic.gdx.graphics.Color lightColor, float lightAmount, float flickerSpeed)
A convenience method that handles blending the background color with a specified light color, by a specific amount, without putting a char on the screen; as a whole this affects one x,y position.void
putWithConsistentLight(int x, int y, float background, float lightColor, float lightAmount)
A convenience method that handles blending the background color with a specified light color, by a specific amount, without putting a char on the screen; as a whole this affects one x,y position.void
putWithConsistentLight(int x, int y, float background, float lightColor, float lightAmount, float flickerSpeed)
A convenience method that handles blending the background color with a specified light color, by a specific amount, without putting a char on the screen; as a whole this affects one x,y position.void
putWithConsistentLight(int x, int y, com.badlogic.gdx.graphics.Color background, com.badlogic.gdx.graphics.Color lightColor, float lightAmount)
A convenience method that handles blending the background color with a specified light color, by a specific amount, without putting a char on the screen; as a whole this affects one x,y position.void
putWithConsistentLight(int x, int y, com.badlogic.gdx.graphics.Color background, com.badlogic.gdx.graphics.Color lightColor, float lightAmount, float flickerSpeed)
A convenience method that handles blending the background color with a specified light color, by a specific amount, without putting a char on the screen; as a whole this affects one x,y position.void
putWithLight(int x, int y, char c, float foreground, float background, float lightColor, double lightAmount)
A convenience method that handles blending the background color with a specified light color, by a specific amount, while also putting a char on the screen; as a whole this affects one x,y position.void
putWithLight(int x, int y, char c, float foreground, float background, float lightColor, float lightAmount)
A convenience method that handles blending the background color with a specified light color, by a specific amount, while also putting a char on the screen; as a whole this affects one x,y position.void
putWithLight(int x, int y, char c, float foreground, float background, float lightColor, float lightAmount, Noise.Noise3D flicker)
A convenience method that handles blending the background color with a specified light color, by a specific amount that will be adjusted by the givenNoise.Noise3D
object, while also putting a char on the screen; as a whole this affects one x,y position and will change what it puts as the time (in milliseconds) changes.void
putWithLight(int x, int y, char c, com.badlogic.gdx.graphics.Color foreground, com.badlogic.gdx.graphics.Color background, com.badlogic.gdx.graphics.Color lightColor, double lightAmount)
A convenience method that handles blending the background color with a specified light color, by a specific amount, while also putting a char on the screen; as a whole this affects one x,y position.void
putWithLight(int x, int y, char c, com.badlogic.gdx.graphics.Color foreground, com.badlogic.gdx.graphics.Color background, com.badlogic.gdx.graphics.Color lightColor, float lightAmount)
A convenience method that handles blending the background color with a specified light color, by a specific amount, while also putting a char on the screen; as a whole this affects one x,y position.void
putWithLight(int x, int y, char c, com.badlogic.gdx.graphics.Color foreground, com.badlogic.gdx.graphics.Color background, com.badlogic.gdx.graphics.Color lightColor, float lightAmount, Noise.Noise3D flicker)
A convenience method that handles blending the background color with a specified light color, by a specific amount that will be adjusted by the givenNoise.Noise3D
object, while also putting a char on the screen; as a whole this affects one x,y position and will change what it puts as the time (in milliseconds) changes.void
putWithLight(int x, int y, float background, float lightColor, double lightAmount)
A convenience method that handles blending the background color with a specified light color, by a specific amount, without putting a char on the screen; as a whole this affects one x,y position.void
putWithLight(int x, int y, float background, float lightColor, float lightAmount)
A convenience method that handles blending the background color with a specified light color, by a specific amount, without putting a char on the screen; as a whole this affects one x,y position.void
putWithLight(int x, int y, float background, float lightColor, float lightAmount, Noise.Noise3D flicker)
A convenience method that handles blending the background color with a specified light color, by a specific amount that will be adjusted by the givenNoise.Noise3D
object, without putting a char on the screen; as a whole this affects one x,y position and will change what it puts as the time (in milliseconds) changes.void
putWithLight(int x, int y, com.badlogic.gdx.graphics.Color background, com.badlogic.gdx.graphics.Color lightColor, double lightAmount)
A convenience method that handles blending the background color with a specified light color, by a specific amount, without putting a char on the screen; as a whole this affects one x,y position.void
putWithLight(int x, int y, com.badlogic.gdx.graphics.Color background, com.badlogic.gdx.graphics.Color lightColor, float lightAmount)
A convenience method that handles blending the background color with a specified light color, by a specific amount, without putting a char on the screen; as a whole this affects one x,y position.void
putWithLight(int x, int y, com.badlogic.gdx.graphics.Color background, com.badlogic.gdx.graphics.Color lightColor, float lightAmount, Noise.Noise3D flicker)
A convenience method that handles blending the background color with a specified light color, by a specific amount that will be adjusted by the givenNoise.Noise3D
object, without putting a char on the screen; as a whole this affects one x,y position and will change what it puts as the time (in milliseconds) changes.void
putWithReverseConsistentLight(int x, int y, char c, float foreground, float background, float lightColor, float lightAmount)
A convenience method that handles blending the foreground color with a specified light color, by a specific amount, without putting a char on the screen; as a whole this affects one x,y position and placed the background as-is.void
putWithReverseConsistentLight(int x, int y, char c, float foreground, float background, float lightColor, float lightAmount, float flickerSpeed)
A convenience method that handles blending the foreground color with a specified light color, by a specific amount, without putting a char on the screen; as a whole this affects one x,y position and placed the background as-is.void
putWithReverseConsistentLight(int x, int y, char c, com.badlogic.gdx.graphics.Color foreground, com.badlogic.gdx.graphics.Color background, com.badlogic.gdx.graphics.Color lightColor, double lightAmount, float flickerSpeed)
A convenience method that handles blending the background color with a specified light color, by a specific amount, without putting a char on the screen; as a whole this affects one x,y position.void
putWithReverseConsistentLight(int x, int y, char c, com.badlogic.gdx.graphics.Color foreground, com.badlogic.gdx.graphics.Color background, com.badlogic.gdx.graphics.Color lightColor, float lightAmount)
A convenience method that handles blending the background color with a specified light color, by a specific amount, without putting a char on the screen; as a whole this affects one x,y position.void
putWithReverseConsistentLight(int x, int y, char c, com.badlogic.gdx.graphics.Color foreground, com.badlogic.gdx.graphics.Color background, com.badlogic.gdx.graphics.Color lightColor, float lightAmount, float flickerSpeed)
A convenience method that handles blending the background color with a specified light color, by a specific amount, without putting a char on the screen; as a whole this affects one x,y position.void
putWithReverseLight(int x, int y, char c, float foreground, float background, float lightColor, double lightAmount)
A convenience method that handles blending the background color with a specified light color, by a specific amount, while also putting a char on the screen; as a whole this affects one x,y position.void
putWithReverseLight(int x, int y, char c, float foreground, float background, float lightColor, float lightAmount)
A convenience method that handles blending the background color with a specified light color, by a specific amount, while also putting a char on the screen; as a whole this affects one x,y position.void
recallToGrid(TextCellFactory.Glyph glyph)
Brings a Glyph back into normal rendering, removing it from the Glyphs this class knows about and filling the grid's char at the Glyph's position in the first layer with the Glyph's char and color.void
recallToGrid(TextCellFactory.Glyph glyph, int layer)
Brings a Glyph back into normal rendering, removing it from the Glyphs this class knows about and filling the grid's char at the Glyph's position in the given layer with the Glyph's char and color.void
recolor(float delay, int x, int y, float encodedColor, float duration)
Changes the background at position x,y so it becomes the given encodedColor, waiting fordelay
(in seconds) before performing it, taking duration seconds.void
recolor(float delay, int x, int y, float encodedColor, float duration, Runnable postRunnable)
Changes the background at position x,y so it becomes the given encodedColor, waiting fordelay
(in seconds) before performing it, taking duration seconds.void
recolor(float delay, int x, int y, int layer, float encodedColor, float duration)
Changes the foreground in the given layer at position x,y so it becomes the given encodedColor, waiting fordelay
(in seconds) before performing it, taking duration seconds.void
recolor(float delay, int x, int y, int layer, float encodedColor, float duration, Runnable postRunnable)
Changes the foreground in the given layer at position x,y so it becomes the given encodedColor, waiting fordelay
(in seconds) before performing it, taking duration seconds.void
recolor(int x, int y, float encodedColor, float duration)
Changes the background at position x,y so it becomes the given encodedColor, taking duration seconds.void
recolor(int x, int y, int layer, float encodedColor, float duration)
Changes the foreground in the given layer at position x,y so it becomes the given encodedColor, taking duration seconds.void
recolor(int x, int y, int layer, com.badlogic.gdx.graphics.Color color, float duration)
Changes the foreground in the given layer at position x,y so it becomes the given color, taking duration seconds.void
recolor(int x, int y, com.badlogic.gdx.graphics.Color color, float duration)
Changes the background at position x,y so it becomes the given color, taking duration seconds.void
removeGlyph(TextCellFactory.Glyph glyph)
A way to remove a Glyph from the group of glyphs this renders, while also ending any animations or other Actions that the removed Glyph was scheduled to perform.void
setBackgrounds(float[][] backgrounds)
Changes the reference this uses for the float array for background colors; this will not accept null parameters, nor will it accept any 2D array with dimensions that do not match the (unchanging) gridWidth and gridHeight of this SparseLayers.protected void
setColorCenter(IColorCenter<com.badlogic.gdx.graphics.Color> icc)
Method to change the backingIColorCenter
.void
setDefaultBackground(com.badlogic.gdx.graphics.Color color)
Sets the default background color.void
setDefaultForeground(com.badlogic.gdx.graphics.Color color)
Sets the default foreground color.void
setFont(TextCellFactory font)
Sets the TextCellFactory this uses to draw and size its text items and cells.void
setLayer(int layerNumber, SparseTextMap contents)
Sets the SparseTextMap associated with the given layerNumber to the given contents.void
setScc(IColorCenter<com.badlogic.gdx.graphics.Color> scc)
Sets the IColorCenter for Color objects that this uses to cache and modify Colors given to it; does not accept null parameters.SparseLayers
setTextSize(float wide, float high)
Changes the width and height of chars the font renders, inside the same cell size.void
slide(float delay, TextCellFactory.Glyph glyph, int startX, int startY, int newX, int newY, float duration, Runnable postRunnable)
Slidesglyph
from(xstartX,startY)
to(newx, newy)
after waitingdelay
seconds.void
slide(TextCellFactory.Glyph glyph, int startX, int startY, int newX, int newY, float duration, Runnable postRunnable)
Slidesglyph
from(xstartX,startY)
to(newx, newy)
.void
summon(float startX, float startY, float endX, float endY, char shown, float startColor, float endColor, float duration)
Create a new Glyph at (startX, startY) in world coordinates (often pixels on the screen) using the char shown with the given startColor, and immediately starts changing color to endColor, changing position so it ends at the world coordinates (endX, endY), taking duration seconds to complete before removing the Glyph.void
summon(float delay, float startX, float startY, float endX, float endY, char shown, float startColor, float endColor, float duration, Runnable postRunnable)
Create a new Glyph at (startX, startY) in world coordinates (often pixels on the screen) using the char shown with the given startColor, and after delay seconds, starts changing color to endColor, changing position so it ends at the world coordinates (endX, endY), taking duration seconds to complete before running postRunnable (if it is non-null) and finally removing the Glyph.void
summon(float delay, int startX, int startY, int endX, int endY, char shown, float startColor, float endColor, float duration, Runnable postRunnable)
Create a new Glyph at (startX, startY) using the char shown with the given startColor, and after delay seconds, starts changing color to endColor, changing position so it ends on the cell (endX, endY), taking duration seconds to complete before running postRunnable (if it is non-null) and finally removing the Glyph.void
summon(int startX, int startY, int endX, int endY, char shown, float startColor, float endColor, float duration)
Create a new Glyph at (startX, startY) using the char shown with the given startColor, and immediately starts changing color to endColor, changing position so it ends on the cell (endX, endY), taking duration seconds to complete before removing the Glyph.void
tint(float delay, int x, int y, float encodedColor, float duration, Runnable postRunnable)
Tints the background at position x,y so it becomes the given encodedColor, waiting fordelay
(in seconds) before performing it, then after the tint is complete it returns the cell to its original color, taking duration seconds.void
tint(float delay, int x, int y, int layer, float encodedColor, float duration, Runnable postRunnable)
Tints the foreground in the given layer at position x,y so it becomes the given encodedColor, waiting fordelay
(in seconds) before performing it, then after the tint is complete it returns the cell to its original color, taking duration seconds.void
tint(float delay, TextCellFactory.Glyph glyph, float encodedColor, float duration, Runnable postRunnable)
Tints the given glyph (which may or may not be part of theglyphs
list this holds) so it becomes the given encodedColor, waiting fordelay
(in seconds) before performing it, then after the tint is complete it returns the cell to its original color, taking duration seconds.void
tint(int x, int y, float encodedColor, float duration)
Tints the background at position x,y so it becomes the given encodedColor, then after the tint is complete it returns the cell to its original color, taking duration seconds.void
tint(int x, int y, int layer, float encodedColor, float duration)
Tints the foreground in the given layer at position x,y so it becomes the given encodedColor, then after the tint is complete it returns the cell to its original color, taking duration seconds.void
tint(int x, int y, int layer, com.badlogic.gdx.graphics.Color color, float duration)
Tints the foreground in the given layer at position x,y so it becomes the given encodedColor, then after the tint is complete it returns the cell to its original color, taking duration seconds.void
tint(int x, int y, com.badlogic.gdx.graphics.Color color, float duration)
Tints the background at position x,y so it becomes the given encodedColor, then after the tint is complete it returns the cell to its original color, taking duration seconds.void
tint(TextCellFactory.Glyph glyph, float encodedColor, float duration)
Tints the given glyph (which may or may not be part of theglyphs
list this holds) so it becomes the given encodedColor, then after the tint is complete it returns the cell to its original color, taking duration seconds.void
wiggle(float delay, TextCellFactory.Glyph glyph, float duration, Runnable postRunnable)
Starts a wiggling animation for the object at the given location, after waiting delay seconds, for the given duration in seconds; runs postRunnable afterwards if it is non-null.void
wiggle(TextCellFactory.Glyph glyph, float duration)
Starts an wiggling animation for the object at the given location for the given duration in seconds.float
worldX(int gridX)
Used internally to go between grid positions and world positions.float
worldY(int gridY)
Used internally to go between grid positions and world positions.Methods inherited from class com.badlogic.gdx.scenes.scene2d.Actor
act, addAction, addCaptureListener, addListener, ancestorsVisible, ascendantsVisible, clearActions, clearListeners, clipBegin, clipBegin, clipEnd, debug, drawDebug, drawDebugBounds, fire, firstAscendant, getActions, getCaptureListeners, getColor, getDebug, getHeight, getListeners, getName, getOriginX, getOriginY, getParent, getRight, getRotation, getScaleX, getScaleY, getStage, getTop, getTouchable, getUserObject, getWidth, getX, getX, getY, getY, getZIndex, hasActions, hasKeyboardFocus, hasParent, hasScrollFocus, hit, isAscendantOf, isDescendantOf, isTouchable, isTouchFocusListener, isTouchFocusTarget, isVisible, localToActorCoordinates, localToAscendantCoordinates, localToParentCoordinates, localToScreenCoordinates, localToStageCoordinates, moveBy, notify, parentToLocalCoordinates, positionChanged, remove, removeAction, removeCaptureListener, removeListener, rotateBy, rotationChanged, scaleBy, scaleBy, screenToLocalCoordinates, setBounds, setColor, setColor, setDebug, setHeight, setName, setOrigin, setOrigin, setOriginX, setOriginY, setParent, setPosition, setPosition, setRotation, setScale, setScale, setScaleX, setScaleY, setSize, setStage, setTouchable, setUserObject, setVisible, setWidth, setX, setX, setY, setY, setZIndex, sizeBy, sizeBy, sizeChanged, stageToLocalCoordinates, toBack, toFront, toString
-
Field Details
-
gridWidth
-
gridHeight
-
backgrounds
A 2D float array of background colors as packed floats. Must have dimensions matchinggridWidth
andgridHeight
, and must be non-null with non-null interior arrays, but can otherwise be assigned 2D float arrays from other sources (that use floats to represent colors, not just any number). -
defaultForeground
The default foreground color when none is specified, as a Color object. Defaults to white. -
defaultBackground
The default foreground color when none is specified, as a Color object. Defaults to white. -
defaultPackedForeground
The value ofdefaultForeground
as a float, for easier usage with the methods that use floats for colors. Defaults to white. -
defaultPackedBackground
The value ofdefaultForeground
as a float, for easier usage with the methods that use floats for colors. Defaults to white. -
layers
A list of SparseTextMap objects, with each representing a foreground layer. -
mapping
-
font
The TextCellFactory that is used to determine font size as well as cell size; must be initialized, usually usingTextCellFactory.initBySize()
, if this is changed after construction. -
animationCount
Deprecated.UsehasActiveAnimations()
instead of adjusting this manuallyWill always be 0 unless user code affects it; usehasActiveAnimations()
to track animations instead. The approach of tracking animations via a counter was prone to error when multiple effects might remove a Glyph or adjust the animationCount in one direction but not the other. This could result in never-ending phases of a game where input wasn't handled because animationCount was greater than 0, but whatever effect was supposed to reduce animationCount would never happen. -
glyphs
A list of individually-movable Glyph objects. This field is public, and though it shouldn't be assigned null (you don't really need to be told that), there may be cases where you may need manual control over what Glyph objects should be added or removed from this SparseLayers. -
scc
An IColorCenter to affect color caching and filtering; usually a SquidColorCenter, which can be easily obtained viaDefaultResources.getSCC()
.
-
-
Constructor Details
-
SparseLayers
protected SparseLayers() -
SparseLayers
-
SparseLayers
-
SparseLayers
public SparseLayers(int gridWidth, int gridHeight, float cellWidth, float cellHeight, TextCellFactory font) -
SparseLayers
public SparseLayers(int gridWidth, int gridHeight, float cellWidth, float cellHeight, TextCellFactory font, float xOffset, float yOffset)
-
-
Method Details
-
getLayerCount
Gets the number of layers currently used in this SparseLayers; if a layer is put into that is equal to or greater than this layer count, then a new layer is created to hold the latest placement. It is recommended that you assign to the layer equal to the result of this method if you want to add a layer. You can add to layers that are higher than this result, and can technically do so out of order, but this just gets confusing because their ordering won't be related to the numbers of the layers.- Returns:
- the current number of layers in this SparseLayers
-
getLayer
Gets the layer, as a SparseTextMap, that is associated with the given int. If none is associated, this returns null. The associating number does not necessarily have to be less than the number of layers in this SparseLayers. Returns a direct reference to the SparseTextMap layer.- Parameters:
layer
- the int that is associated with a layer, usually the int used to add to that layer.- Returns:
- the SparseTextMap layer associated with the given int
-
setLayer
Sets the SparseTextMap associated with the given layerNumber to the given contents. If layerNumber is too high to set an existing layer, this will add contents as a new layer on top of the others.- Parameters:
layerNumber
- must be 0 or greatercontents
- a SparseTextMap, possibly obtained withgetLayer(int)
-
findLayer
Finds the layer number associated with layerMap, or -1 if the given SparseTextMap is not in this SparseLayers.- Parameters:
layerMap
- a SparseTextMap that was likely returned byaddLayer()
- Returns:
- the int the layer is associated with, or -1 if it is not in this SparseLayers.
-
addLayer
Adds a layer as a SparseTextMap to this SparseLayers and returns the one just added. The layer will generally be associated with a layer number equal to the number of layers currently present, and will be rendered over the existing layers. It might not be associated with the same number if layers were added out-of-order or with skips between associations. If you want to add a layer at some alternate layer number (which can be confusing but may be needed for some reason), there is another overload that allows you to specify the association number. If you may have added some layers out of order or skipped some numbers, you can usefindLayer(SparseTextMap)
on the returned SparseTextMap to get its association number.- Returns:
- a SparseTextMap that was just added; null if something went wrong
-
addLayer
Adds a layer as a SparseTextMap to this SparseLayers and returns the one just added, or returns an existing layer if one is already associated with the given number. The layer can be greater than the number of layers currently present, which will add a layer to be rendered over the existing layers, but the number that refers to that layer will not change. It is recommended that to add a layer, you only add at the value equal togetLayerCount()
, which will maintain the order and layer numbers in a sane way, and this is the behavior of the addLayer overload that does not take a parameter.- Parameters:
association
- the number to associate the layer with; should usually be between 0 andgetLayerCount()
inclusive- Returns:
- a SparseTextMap that either was just added or was already associated with the given layer number; null if something went wrong
-
put
Puts the characterc
at(x, y)
with the default foreground. Does not change the background.- Specified by:
put
in interfaceIPackedColorPanel
- Parameters:
x
- the x position to place the char aty
- the y position to place the char atc
- the char to place, using the default foreground color
-
put
Puts the ICellVisible cell at the position x,y; does not change the background. Ifcell.getPackedColor()
is 0f, then this does not change the foreground contents either. Does not filter the given colors.- Parameters:
x
- the x position to place the char aty
- the y position to place the char atcell
- an ICellVisible, which is often implemented outside of SquidLib; this uses its char and color.
-
put
public void put(int xOffset, int yOffset, String string, com.badlogic.gdx.graphics.Color foreground)Puts the given string horizontally with the first character at the given offset. Uses the given color for the text and does not change the background color at all.Does not word wrap. Characters that are not renderable (due to being at negative offsets or offsets greater than the grid size) will not be shown but will not cause any malfunctions.
- Specified by:
put
in interfaceIPackedColorPanel
- Parameters:
xOffset
- the x coordinate of the first characteryOffset
- the y coordinate of the first characterstring
- the characters to be displayedforeground
- the color to use for the text
-
put
public void put(int xOffset, int yOffset, IColoredString<? extends com.badlogic.gdx.graphics.Color> cs)Puts the given string horizontally with the first character at the given offset, using the colors thatcs
provides. Does not change the background colors. Does filter the colors from cs if the color center this uses is set up to filter colors.Does not word wrap. Characters that are not renderable (due to being at negative offsets or offsets greater than the grid size) will not be shown but will not cause any malfunctions.
- Specified by:
put
in interfaceIPackedColorPanel
- Parameters:
xOffset
- the x coordinate of the first characteryOffset
- the y coordinate of the first charactercs
- anIColoredString
with potentially multiple colors
-
put
Puts the characterc
at(x, y)
with somecolor
. Does not change the background colors.- Specified by:
put
in interfaceIPackedColorPanel
- Parameters:
x
- the x position to place the char aty
- the y position to place the char atc
- the char to placecolor
- the color to use for c; if null or fully transparent, nothing will change in the foreground
-
put
Sets the background colors to match the given Color 2D array. If the colors argument is null, does nothing. This will filter each Color in colors if the color center this uses has a filter.- Parameters:
colors
- the background colors for the given chars
-
put
Sets the background colors to match the given 2D array of colors as packed floats. If the colors argument is null, does nothing. This will not filter the passed colors at all.- Parameters:
colors
- the background colors to use for this SparseLayers
-
putChars
Places the given char 2D array, if-non-null, in the default foreground color starting at x=0, y=0.- Parameters:
chars
- a 2D char array to place without affecting background colors; these chars will use the default foreground color
-
putChars
Places the given char 2D array, if-non-null, in the foreground starting at x=0, y=0. Each char will be drawn in the corresponding foreground color from foregrounds.- Parameters:
chars
- a 2D char array to place without affecting background colorsforegrounds
- a 2D float array of encoded colors as produced byColor.toFloatBits()
; applies to char foregrounds
-
putChars
Places the given char 2D array, if-non-null, in the foreground starting at x=0, y=0. Each char will be drawn in the corresponding foreground color from foregrounds.- Parameters:
chars
- a 2D char array to place without affecting background colorsforegrounds
- a 2D array of libGDX colors (any may also be an SColor or other subclass); applies to char foregrounds
-
put
Places the given char 2D array, if-non-null, in the default foreground color starting at x=0, y=0, while also setting the background colors to match the given Color 2D array. If the colors argument is null, does nothing. If the chars argument is null, only affects the background colors. This will filter each Color in colors if the color center this uses has a filter.- Specified by:
put
in interfaceIPackedColorPanel
- Parameters:
chars
- Can benull
, indicating that only colors must be put.colors
- the background colors for the given chars
-
put
Places the given char 2D array, if-non-null, in the default foreground color starting at x=0, y=0, while also setting the background colors to match the given 2D array of colors as packed floats. If the colors argument is null, does nothing. If the chars argument is null, only affects the background colors. This will not filter the passed colors at all.- Parameters:
chars
- Can benull
, indicating that only colors must be put.colors
- the background colors for the given chars
-
put
public void put(char[][] chars, com.badlogic.gdx.graphics.Color[][] fgColors, com.badlogic.gdx.graphics.Color[][] bgColors)Places the given char 2D array, if-non-null, with the given foreground colors in the first Color 2D array, starting at x=0, y=0, while also setting the background colors to match the second Color 2D array. If the bgColors argument is null, only affects foreground chars and colors. If the chars argument or the fgColors argument is null, only affects the background colors. Any positions where a Color in fgColors is null will not have a char placed (this can be used to restrict what is placed). This will filter each Color in the background and foreground if the color center this uses has a filter.- Parameters:
chars
- Can benull
, indicating that only colors must be put.fgColors
- the foreground Colors for the given charsbgColors
- the background Colors for the given chars
-
put
Places the given char 2D array, if-non-null, with the given foreground colors in the first float 2D array, starting at x=0, y=0, while also setting the background colors to match the second float 2D array. If the bgColors argument is null, only affects foreground chars and colors. If the chars argument or the fgColors argument is null, only affects the background colors. Any positions where a float in fgColors is 0 will not have a char placed (this can be used to restrict what is placed). This will not filter any colors.- Parameters:
chars
- Can benull
, indicating that only colors must be put.fgColors
- the foreground colors for the given chars, as packed floatsbgColors
- the background colors for the given chars, as packed floats
-
gridWidth
- Specified by:
gridWidth
in interfaceIPackedColorPanel
- Returns:
- The number of cells that this panel spans, horizontally.
-
gridHeight
- Specified by:
gridHeight
in interfaceIPackedColorPanel
- Returns:
- The number of cells that this panel spans, vertically.
-
getGridWidth
The same asgridWidth()
; here for compatibility with SquidPanel.- Returns:
- The number of cells that this panel spans, horizontally.
-
getGridHeight
The same asgridHeight()
; here for compatibility with SquidPanel.- Returns:
- The number of cells that this panel spans, vertically.
-
cellWidth
- Specified by:
cellWidth
in interfaceIPackedColorPanel
- Returns:
- The width of a cell, in number of pixels.
-
cellHeight
- Specified by:
cellHeight
in interfaceIPackedColorPanel
- Returns:
- The height of a cell, in number of pixels.
-
setTextSize
Changes the width and height of chars the font renders, inside the same cell size. Primarily useful if the font has issues and doesn't line up visually; some older versions of .fnt files distributed with SquidLib had this type of problem (and some may still). Provides compatibility with SquidPanel code.- Parameters:
wide
- width in approximate pixelshigh
- height in approximate pixels- Returns:
- this for chaining.
-
setDefaultForeground
Sets the default foreground color. This Color can be null, which will usually not be rendered unless a different color is specified.- Specified by:
setDefaultForeground
in interfaceIPackedColorPanel
- Parameters:
color
- a libGDX Color object or an extension of Color, such as SColor
-
getDefaultForegroundColor
- Specified by:
getDefaultForegroundColor
in interfaceIPackedColorPanel
- Returns:
- The default foreground color (if none was set with
setDefaultForeground(Color)
), or the last color set withsetDefaultForeground(Color)
. This Color can be null which will usually not be rendered unless a different color is specified.
-
setDefaultBackground
Sets the default background color. This Color can be null, which will usually not be rendered unless a different color is specified.- Parameters:
color
- a libGDX Color object or an extension of Color, such as SColor
-
getDefaultBackgroundColor
- Returns:
- The default background color (if none was set with
setDefaultBackground(Color)
), or the last color set withsetDefaultBackground(Color)
. This can be null, which will usually not be rendered unless a different color is specified.
-
setColorCenter
Method to change the backingIColorCenter
. Note that the IColorCenter is not used to filter floats that encode colors, so passing the result ofColor.toFloatBits()
can be used to bypass the filtering if you want a color to be used exactly.- Parameters:
icc
- an IColorCenter that can cache and possibly filterColor
objects
-
getColorCenter
Gets the IColorCenter this can use to filter Color objects; this is usually aSquidColorCenter
. Note that the IColorCenter is not used to filter floats that encode colors, so passing the result ofColor.toFloatBits()
can be used to bypass the filtering if you want a color to be used exactly.- Returns:
- the IColorCenter this uses
-
put
public void put(int x, int y, char c, com.badlogic.gdx.graphics.Color foreground, com.badlogic.gdx.graphics.Color background)Puts the char c at the position x,y with the given foreground and background colors. If foreground is null or is fully transparent (all channels 0), then this does not change the foreground contents. If background is null or is fully transparent, this does not change the background. Uses the color center to potentially filter the given colors; this can be changed withsetColorCenter(IColorCenter)
.- Parameters:
x
- the x position to place the char aty
- the y position to place the char atc
- the char to placeforeground
- the color to use for c; if null or fully transparent, nothing will change in the foregroundbackground
- the color to use for the cell; if null or fully transparent, nothing will change in the background
-
put
Puts the ICellVisible cell at the position x,y with the given background color as an encoded float, such as those produced byColor.toFloatBits()
. Ifcell.getPackedColor()
is 0f, then this does not change the foreground contents. If background is 0f, this does not change the background. Does not filter the given colors.- Parameters:
x
- the x position to place the char aty
- the y position to place the char atcell
- an ICellVisible, which is often implemented outside of SquidLib; this uses its char and color.background
- the color to use for the cell; if null or fully transparent, nothing will change in the background
-
put
Puts the char c at the position x,y with the given foreground and background colors as encoded floats, such as those produced byColor.toFloatBits()
. If foreground is 0f, then this does not change the foreground contents. If background is 0f, this does not change the background. Does not filter the given colors.- Parameters:
x
- the x position to place the char aty
- the y position to place the char atc
- the char to placeforeground
- the color to use for c; if 0f, nothing will change in the foregroundbackground
- the color to use for the cell; if null or fully transparent, nothing will change in the background
-
put
Puts the char c at the position x,y with the given foreground color as an encoded float (the kind produced byColor.toFloatBits()
). If foreground is 0f, then this does nothing. Does not filter the given color.- Specified by:
put
in interfaceIPackedColorPanel
- Parameters:
x
- the x position to place the char aty
- the y position to place the char atc
- the char to placeforeground
- the color to use for c; if 0f, this call does nothing
-
put
public void put(int x, int y, char c, com.badlogic.gdx.graphics.Color foreground, com.badlogic.gdx.graphics.Color background, int layer)Puts the char c at the position x,y in the requested layer with the given foreground and background colors. If foreground is null or is fully transparent (all channels 0), then this does not change the foreground contents. If background is null or is fully transparent, this does not change the background. Uses the color center to potentially filter the given colors; this can be changed withsetColorCenter(IColorCenter)
. The layer can be greater than the number of layers currently present, which will add a layer to be rendered over the existing layers, but the number that refers to that layer will not change. It is recommended that to add a layer, you only add at the value equal togetLayerCount()
, which will maintain the order and layer numbers in a sane way.- Parameters:
x
- the x position to place the char aty
- the y position to place the char atc
- the char to placeforeground
- the color to use for c; if null or fully transparent, nothing will change in the foregroundbackground
- the color to use for the cell; if null or fully transparent, nothing will change in the backgroundlayer
- the layer to place the colorful char into; should usually be between 0 andgetLayerCount()
inclusive
-
put
Puts the char c at the position x,y in the requested layer with the given foreground and background colors as encoded floats, such as those produced byColor.toFloatBits()
. If foreground is 0f, then this does not change the foreground contents. If background is 0f, this does not change the background. Does not filter the given colors. The layer can be greater than the number of layers currently present, which will add a layer to be rendered over the existing layers, but the number that refers to that layer will not change. It is recommended that to add a layer, you only add at the value equal togetLayerCount()
, which will maintain the order and layer numbers in a sane way.- Parameters:
x
- the x position to place the char aty
- the y position to place the char atc
- the char to placeforeground
- the color to use for c; if 0f, nothing will change in the foregroundbackground
- the color to use for the cell; if null or fully transparent, nothing will change in the backgroundlayer
- the layer to place the colorful char into; should usually be between 0 andgetLayerCount()
inclusive
-
put
public void put(int x, int y, String text, com.badlogic.gdx.graphics.Color foreground, com.badlogic.gdx.graphics.Color background)Puts text at the position x,y with the given foreground and background colors. If foreground is null or is fully transparent (all channels 0), then this does not change the foreground contents. If background is null or is fully transparent, this does not change the background. Uses the color center to potentially filter the given colors; this can be changed withsetColorCenter(IColorCenter)
.- Parameters:
x
- the x position to place the String aty
- the y position to place the String attext
- the String to placeforeground
- the color to use for text; if null or fully transparent, nothing will change in the foregroundbackground
- the color to use for the cells; if null or fully transparent, nothing will change in the background
-
put
Puts text at the position x,y with the given foreground and background colors as encoded floats, such as those produced byColor.toFloatBits()
. If foreground is 0f, then this does not change the foreground contents. If background is 0f, this does not change the background. Does not filter the given colors.- Parameters:
x
- the x position to place the String aty
- the y position to place the String attext
- the String to placeforeground
- the color to use for text; if 0f, nothing will change in the foregroundbackground
- the color to use for the cells; if null or fully transparent, nothing will change in the background
-
put
public void put(int x, int y, String text, com.badlogic.gdx.graphics.Color foreground, com.badlogic.gdx.graphics.Color background, int layer)Puts text at the position x,y in the requested layer with the given foreground and background colors. If foreground is null or is fully transparent (all channels 0), then this does not change the foreground contents. If background is null or is fully transparent, this does not change the background. Uses the color center to potentially filter the given colors; this can be changed withsetColorCenter(IColorCenter)
. The layer can be greater than the number of layers currently present, which will add a layer to be rendered over the existing layers, but the number that refers to that layer will not change. It is recommended that to add a layer, you only add at the value equal togetLayerCount()
, which will maintain the order and layer numbers in a sane way.- Parameters:
x
- the x position to place the String aty
- the y position to place the String attext
- the String to placeforeground
- the color to use for text; if null or fully transparent, nothing will change in the foregroundbackground
- the color to use for the cells; if null or fully transparent, nothing will change in the backgroundlayer
- the layer to place the colorful char into; should usually be between 0 andgetLayerCount()
inclusive
-
put
Puts text at the position x,y in the requested layer with the given foreground and background colors as encoded floats, such as those produced byColor.toFloatBits()
. If foreground is 0f, then this does not change the foreground contents. If background is 0f, this does not change the background. Does not filter the given colors. The layer can be greater than the number of layers currently present, which will add a layer to be rendered over the existing layers, but the number that refers to that layer will not change. It is recommended that to add a layer, you only add at the value equal togetLayerCount()
, which will maintain the order and layer numbers in a sane way.- Parameters:
x
- the x position to place the String aty
- the y position to place the String attext
- the String to placeforeground
- the color to use for text; if 0f, nothing will change in the foregroundbackground
- the color to use for the cells; if null or fully transparent, nothing will change in the backgroundlayer
- the layer to place the colorful char into; should usually be between 0 andgetLayerCount()
inclusive
-
put
Changes the background at position x,y to the given Color. If the color is null, then this will make the background fully transparent at the specified position.- Specified by:
put
in interfaceIPackedColorPanel
- Parameters:
x
- where to change the background color, x-coordinatey
- where to change the background color, y-coordinatecolor
- the Color to change to; if null will be considered fully transparent
-
put
Changes the background at position x,y to the given color as an encoded float. The color can be transparent, which will show through to whatever is behind this SparseLayers, or the color the screen was last cleared with. Unlike other methods in this class, a float equal to 0f will be used instead of being used to skip over a cell, and will change the background at the given position to fully transparent.- Specified by:
put
in interfaceIPackedColorPanel
- Parameters:
x
- where to change the background color, x-coordinatey
- where to change the background color, y-coordinatecolor
- the color, as an encoded float, to change to; may be transparent, and considers 0f a valid color
-
putWithLight
public void putWithLight(int x, int y, com.badlogic.gdx.graphics.Color background, com.badlogic.gdx.graphics.Color lightColor, float lightAmount)A convenience method that handles blending the background color with a specified light color, by a specific amount, without putting a char on the screen; as a whole this affects one x,y position.- Parameters:
x
- the x position, in cellsy
- the y position, in cellsbackground
- the "base" color to use for the background, which will be combined with lightColor, as a libGDX ColorlightColor
- the color to mix with the background, as a libGDX ColorlightAmount
- a float that determines how much lightColor should affect background by; not strictly limited to between 0 and 1, and negative values can be given to favor background more
-
putWithLight
public void putWithLight(int x, int y, com.badlogic.gdx.graphics.Color background, com.badlogic.gdx.graphics.Color lightColor, double lightAmount)A convenience method that handles blending the background color with a specified light color, by a specific amount, without putting a char on the screen; as a whole this affects one x,y position.- Parameters:
x
- the x position, in cellsy
- the y position, in cellsbackground
- the "base" color to use for the background, which will be combined with lightColor, as a libGDX ColorlightColor
- the color to mix with the background, as a libGDX ColorlightAmount
- a double that determines how much lightColor should affect background by; not strictly limited to between 0 and 1, and negative values can be given to favor background more
-
putWithLight
public void putWithLight(int x, int y, char c, com.badlogic.gdx.graphics.Color foreground, com.badlogic.gdx.graphics.Color background, com.badlogic.gdx.graphics.Color lightColor, float lightAmount)A convenience method that handles blending the background color with a specified light color, by a specific amount, while also putting a char on the screen; as a whole this affects one x,y position.- Parameters:
x
- the x position, in cellsy
- the y position, in cellsc
- the char to put in the foregroundforeground
- the color to use for the foreground, as a libGDX Color; if null, this won't place a foreground charbackground
- the "base" color to use for the background, which will be combined with lightColor, as a libGDX ColorlightColor
- the color to mix with the background, as a libGDX ColorlightAmount
- a float that determines how much lightColor should affect background by; not strictly limited to between 0 and 1, and negative values can be given to favor background more
-
putWithLight
public void putWithLight(int x, int y, char c, com.badlogic.gdx.graphics.Color foreground, com.badlogic.gdx.graphics.Color background, com.badlogic.gdx.graphics.Color lightColor, double lightAmount)A convenience method that handles blending the background color with a specified light color, by a specific amount, while also putting a char on the screen; as a whole this affects one x,y position.- Parameters:
x
- the x position, in cellsy
- the y position, in cellsc
- the char to put in the foregroundforeground
- the color to use for the foreground, as a libGDX Color; if null, this won't place a foreground charbackground
- the "base" color to use for the background, which will be combined with lightColor, as a libGDX ColorlightColor
- the color to mix with the background, as a libGDX ColorlightAmount
- a double that determines how much lightColor should affect background by; not strictly limited to between 0 and 1, and negative values can be given to favor background more
-
putWithConsistentLight
public void putWithConsistentLight(int x, int y, float background, float lightColor, float lightAmount)A convenience method that handles blending the background color with a specified light color, by a specific amount, without putting a char on the screen; as a whole this affects one x,y position. This will use the same brightness for all cells given identical lightAmount values when this is called; this differentiates it fromputWithLight(int, int, float, float, float, Noise.Noise3D)
, which would light "splotches" of map with brighter or darker color. Instead, if lightAmount is obtained via SquidLib'sFOV
class, then all cells at a short distance from an FOV center will be lit brightly and cells far away will flicker in and out of view.- Parameters:
x
- the x position, in cellsy
- the y position, in cellsbackground
- the "base" color to use for the background, which will be combined with lightColor, as a packed float colorlightColor
- the color to mix with the background, as a packed float colorlightAmount
- a float that determines how much lightColor should affect background by; not strictly limited to between 0 and 1, and negative values can be given to favor background more
-
putWithConsistentLight
public void putWithConsistentLight(int x, int y, float background, float lightColor, float lightAmount, float flickerSpeed)A convenience method that handles blending the background color with a specified light color, by a specific amount, without putting a char on the screen; as a whole this affects one x,y position. This will use the same brightness for all cells given identical lightAmount values when this is called; this differentiates it fromputWithLight(int, int, float, float, float, Noise.Noise3D)
, which would light "splotches" of map with brighter or darker color. Instead, if lightAmount is obtained via SquidLib'sFOV
class, then all cells at a short distance from an FOV center will be lit brightly and cells far away will flicker in and out of view.- Parameters:
x
- the x position, in cellsy
- the y position, in cellsbackground
- the "base" color to use for the background, which will be combined with lightColor, as a packed float colorlightColor
- the color to mix with the background, as a packed float colorlightAmount
- a float that determines how much lightColor should affect background by; not strictly limited to between 0 and 1, and negative values can be given to favor background moreflickerSpeed
- a small float multiplier applied to the time in milliseconds; often between 0.0005f and 0.005f
-
calculateConsistentLightModifier
Gets a modifier that should be given tocalculateConsistentLightAmount(float, float)
; this only needs to be called at most once per frame. It uses a flickerSpeed of 0.0015f, if you want to compare it tocalculateConsistentLightModifier(float)
.- Returns:
- a modifier to pass to
calculateConsistentLightAmount(float, float)
-
calculateConsistentLightModifier
Gets a modifier that should be given tocalculateConsistentLightAmount(float, float)
; this only needs to be called at most once per frame. It uses the given flickerSpeed; a common example value is 0.0015f.- Returns:
- a modifier to pass to
calculateConsistentLightAmount(float, float)
-
calculateConsistentLightAmount
Allows you to reproduce the effects ofputWithConsistentLight(int, int, char, float, float, float, double, float)
without recalculating the modifier many times per frame. You should typically calculate the modifier once per frame usingcalculateConsistentLightModifier()
. This method should usually be called once per cell that needs consistent lighting that flickers the same in all directions.- Parameters:
lightAmount
- typically from FOV or some other way of generating a float with lower values further from a position (such as a light)modifier
- calculated previously bycalculateConsistentLightModifier()
, which should be done per-frame- Returns:
- the adjusted light amount to mimic the appearance of
putWithConsistentLight(int, int, char, float, float, float, double, float)
-
putWithConsistentLight
public void putWithConsistentLight(int x, int y, com.badlogic.gdx.graphics.Color background, com.badlogic.gdx.graphics.Color lightColor, float lightAmount)A convenience method that handles blending the background color with a specified light color, by a specific amount, without putting a char on the screen; as a whole this affects one x,y position. This will use the same brightness for all cells given identical lightAmount values when this is called; this differentiates it fromputWithLight(int, int, float, float, float, Noise.Noise3D)
, which would light "splotches" of map with brighter or darker color. Instead, if lightAmount is obtained via SquidLib'sFOV
class, then all cells at a short distance from an FOV center will be lit brightly and cells far away will flicker in and out of view.- Parameters:
x
- the x position, in cellsy
- the y position, in cellsbackground
- the "base" color to use for the background, which will be combined with lightColor, as a libGDX ColorlightColor
- the color to mix with the background, as a libGDX ColorlightAmount
- a float that determines how much lightColor should affect background by; not strictly limited to between 0 and 1, and negative values can be given to favor background more
-
putWithConsistentLight
public void putWithConsistentLight(int x, int y, com.badlogic.gdx.graphics.Color background, com.badlogic.gdx.graphics.Color lightColor, float lightAmount, float flickerSpeed)A convenience method that handles blending the background color with a specified light color, by a specific amount, without putting a char on the screen; as a whole this affects one x,y position. This will use the same brightness for all cells given identical lightAmount values when this is called; this differentiates it fromputWithLight(int, int, float, float, float, Noise.Noise3D)
, which would light "splotches" of map with brighter or darker color. Instead, if lightAmount is obtained via SquidLib'sFOV
class, then all cells at a short distance from an FOV center will be lit brightly and cells far away will flicker in and out of view.- Parameters:
x
- the x position, in cellsy
- the y position, in cellsbackground
- the "base" color to use for the background, which will be combined with lightColor, as a libGDX ColorlightColor
- the color to mix with the background, as a libGDX ColorlightAmount
- a float that determines how much lightColor should affect background by; not strictly limited to between 0 and 1, and negative values can be given to favor background moreflickerSpeed
- a small float multiplier applied to the time in milliseconds; often between 0.0005f and 0.005f
-
putWithConsistentLight
public void putWithConsistentLight(int x, int y, char c, float foreground, float background, float lightColor, float lightAmount)A convenience method that handles blending the background color with a specified light color, by a specific amount, without putting a char on the screen; as a whole this affects one x,y position. This will use the same brightness for all cells given identical lightAmount values when this is called; this differentiates it fromputWithLight(int, int, float, float, float, Noise.Noise3D)
, which would light "splotches" of map with brighter or darker color. Instead, if lightAmount is obtained via SquidLib'sFOV
class, then all cells at a short distance from an FOV center will be lit brightly and cells far away will flicker in and out of view.- Parameters:
x
- the x position, in cellsy
- the y position, in cellsc
- the char to draw; may be'\0'
to draw a solid blockbackground
- the "base" color to use for the background, which will be combined with lightColor, as a packed float colorlightColor
- the color to mix with the background, as a packed float colorlightAmount
- a float that determines how much lightColor should affect background by; not strictly limited to between 0 and 1, and negative values can be given to favor background more
-
putWithConsistentLight
public void putWithConsistentLight(int x, int y, char c, float foreground, float background, float lightColor, double lightAmount)A convenience method that handles blending the background color with a specified light color, by a specific amount, without putting a char on the screen; as a whole this affects one x,y position. This will use the same brightness for all cells given identical lightAmount values when this is called; this differentiates it fromputWithLight(int, int, float, float, float, Noise.Noise3D)
, which would light "splotches" of map with brighter or darker color. Instead, if lightAmount is obtained via SquidLib'sFOV
class, then all cells at a short distance from an FOV center will be lit brightly and cells far away will flicker in and out of view.- Parameters:
x
- the x position, in cellsy
- the y position, in cellsc
- the char to draw; may be'\0'
to draw a solid blockbackground
- the "base" color to use for the background, which will be combined with lightColor, as a packed float colorlightColor
- the color to mix with the background, as a packed float colorlightAmount
- a double that determines how much lightColor should affect background by; not strictly limited to between 0 and 1, and negative values can be given to favor background more
-
putWithConsistentLight
public void putWithConsistentLight(int x, int y, char c, float foreground, float background, float lightColor, double lightAmount, float flickerSpeed)A convenience method that handles blending the background color with a specified light color, by a specific amount, without putting a char on the screen; as a whole this affects one x,y position. This will use the same brightness for all cells given identical lightAmount values when this is called; this differentiates it fromputWithLight(int, int, float, float, float, Noise.Noise3D)
, which would light "splotches" of map with brighter or darker color. Instead, if lightAmount is obtained via SquidLib'sFOV
class, then all cells at a short distance from an FOV center will be lit brightly and cells far away will flicker in and out of view.- Parameters:
x
- the x position, in cellsy
- the y position, in cellsc
- the char to draw; may be'\0'
to draw a solid blockforeground
- the color to use for the foreground, as a packed float; if 0f, this won't place a foreground charbackground
- the "base" color to use for the background, which will be combined with lightColor, as a packed float colorlightColor
- the color to mix with the background, as a packed float colorlightAmount
- a float that determines how much lightColor should affect background by; not strictly limited to between 0 and 1, and negative values can be given to favor background moreflickerSpeed
- a small float multiplier applied to the time in milliseconds; often between 0.0005f and 0.005f
-
putWithReverseConsistentLight
public void putWithReverseConsistentLight(int x, int y, char c, float foreground, float background, float lightColor, float lightAmount)A convenience method that handles blending the foreground color with a specified light color, by a specific amount, without putting a char on the screen; as a whole this affects one x,y position and placed the background as-is. This will use the same brightness for all cells given identical lightAmount values when this is called; this differentiates it fromputWithLight(int, int, float, float, float, Noise.Noise3D)
, which would light "splotches" of map with brighter or darker color. Instead, if lightAmount is obtained via SquidLib'sFOV
class, then all cells at a short distance from an FOV center will be lit brightly and cells far away will flicker in and out of view.- Parameters:
x
- the x position, in cellsy
- the y position, in cellsc
- the char to draw; may be'\0'
to draw a solid blockforeground
- the "base" color to use for the foreground, which will be combined with lightColor, as a packed float colorbackground
- the "base" color to use for the background, which will used without modification, as a packed float colorlightColor
- the color to mix with the foreground, as a packed float colorlightAmount
- a float that determines how much lightColor should affect foreground by; not strictly limited to between 0 and 1, and negative values can be given to favor foreground more
-
putWithReverseConsistentLight
public void putWithReverseConsistentLight(int x, int y, char c, float foreground, float background, float lightColor, float lightAmount, float flickerSpeed)A convenience method that handles blending the foreground color with a specified light color, by a specific amount, without putting a char on the screen; as a whole this affects one x,y position and placed the background as-is. This will use the same brightness for all cells given identical lightAmount values when this is called; this differentiates it fromputWithLight(int, int, float, float, float, Noise.Noise3D)
, which would light "splotches" of map with brighter or darker color. Instead, if lightAmount is obtained via SquidLib'sFOV
class, then all cells at a short distance from an FOV center will be lit brightly and cells far away will flicker in and out of view.- Parameters:
x
- the x position, in cellsy
- the y position, in cellsc
- the char to draw; may be'\0'
to draw a solid blockforeground
- the "base" color to use for the foreground, which will be combined with lightColor, as a packed float colorbackground
- the "base" color to use for the background, which will used without modification, as a packed float colorlightColor
- the color to mix with the foreground, as a packed float colorlightAmount
- a float that determines how much lightColor should affect foreground by; not strictly limited to between 0 and 1, and negative values can be given to favor foreground moreflickerSpeed
- a small float multiplier applied to the time in milliseconds; often between 0.0005f and 0.005f
-
putWithConsistentLight
public void putWithConsistentLight(int x, int y, char c, com.badlogic.gdx.graphics.Color foreground, com.badlogic.gdx.graphics.Color background, com.badlogic.gdx.graphics.Color lightColor, float lightAmount)A convenience method that handles blending the background color with a specified light color, by a specific amount, without putting a char on the screen; as a whole this affects one x,y position. This will use the same brightness for all cells given identical lightAmount values when this is called; this differentiates it fromputWithLight(int, int, float, float, float, Noise.Noise3D)
, which would light "splotches" of map with brighter or darker color. Instead, if lightAmount is obtained via SquidLib'sFOV
class, then all cells at a short distance from an FOV center will be lit brightly and cells far away will flicker in and out of view.- Parameters:
x
- the x position, in cellsy
- the y position, in cellsc
- the char to draw; may be'\0'
to draw a solid blockforeground
- the "base" color to use for the foreground, which will be combined with lightColor, as a libGDX Colorbackground
- the "base" color to use for the background, which will used without modificationlightColor
- the color to mix with the background, as a libGDX ColorlightAmount
- a float that determines how much lightColor should affect background by; not strictly limited to between 0 and 1, and negative values can be given to favor background more
-
putWithConsistentLight
public void putWithConsistentLight(int x, int y, char c, com.badlogic.gdx.graphics.Color foreground, com.badlogic.gdx.graphics.Color background, com.badlogic.gdx.graphics.Color lightColor, float lightAmount, float flickerSpeed)A convenience method that handles blending the background color with a specified light color, by a specific amount, without putting a char on the screen; as a whole this affects one x,y position. This will use the same brightness for all cells given identical lightAmount values when this is called; this differentiates it fromputWithLight(int, int, float, float, float, Noise.Noise3D)
, which would light "splotches" of map with brighter or darker color. Instead, if lightAmount is obtained via SquidLib'sFOV
class, then all cells at a short distance from an FOV center will be lit brightly and cells far away will flicker in and out of view.- Parameters:
x
- the x position, in cellsy
- the y position, in cellsc
- the char to draw; may be'\0'
to draw a solid blockforeground
- the "base" color to use for the foreground, which will used without modificationbackground
- the "base" color to use for the background, which will be combined with lightColor, as a libGDX ColorlightColor
- the color to mix with the background, as a libGDX ColorlightAmount
- a float that determines how much lightColor should affect background by; not strictly limited to between 0 and 1, and negative values can be given to favor background moreflickerSpeed
- a small float multiplier applied to the time in milliseconds; often between 0.0005f and 0.005f
-
putWithReverseConsistentLight
public void putWithReverseConsistentLight(int x, int y, char c, com.badlogic.gdx.graphics.Color foreground, com.badlogic.gdx.graphics.Color background, com.badlogic.gdx.graphics.Color lightColor, float lightAmount)A convenience method that handles blending the background color with a specified light color, by a specific amount, without putting a char on the screen; as a whole this affects one x,y position. This will use the same brightness for all cells given identical lightAmount values when this is called; this differentiates it fromputWithLight(int, int, float, float, float, Noise.Noise3D)
, which would light "splotches" of map with brighter or darker color. Instead, if lightAmount is obtained via SquidLib'sFOV
class, then all cells at a short distance from an FOV center will be lit brightly and cells far away will flicker in and out of view.
Identical to callingputWithReverseConsistentLight(int, int, char, Color, Color, Color, float, float)
with 0.0015f as the last parameter.- Parameters:
x
- the x position, in cellsy
- the y position, in cellsc
- the char to draw; may be'\0'
to draw a solid blockforeground
- the "base" color to use for the foreground, which will be combined with lightColor, as a libGDX Colorbackground
- the "base" color to use for the background, which will used without modificationlightColor
- the color to mix with the foreground, as a libGDX ColorlightAmount
- a float that determines how much lightColor should affect foreground by; not strictly limited to between 0 and 1, and negative values can be given to favor foreground more
-
putWithReverseConsistentLight
public void putWithReverseConsistentLight(int x, int y, char c, com.badlogic.gdx.graphics.Color foreground, com.badlogic.gdx.graphics.Color background, com.badlogic.gdx.graphics.Color lightColor, float lightAmount, float flickerSpeed)A convenience method that handles blending the background color with a specified light color, by a specific amount, without putting a char on the screen; as a whole this affects one x,y position. This will use the same brightness for all cells given identical lightAmount values when this is called; this differentiates it fromputWithLight(int, int, float, float, float, Noise.Noise3D)
, which would light "splotches" of map with brighter or darker color. Instead, if lightAmount is obtained via SquidLib'sFOV
class, then all cells at a short distance from an FOV center will be lit brightly and cells far away will flicker in and out of view.- Parameters:
x
- the x position, in cellsy
- the y position, in cellsc
- the char to draw; may be'\0'
to draw a solid blockforeground
- the "base" color to use for the foreground, which will be combined with lightColor, as a libGDX Colorbackground
- the "base" color to use for the background, which will used without modificationlightColor
- the color to mix with the foreground, as a libGDX ColorlightAmount
- a float that determines how much lightColor should affect foreground by; not strictly limited to between 0 and 1, and negative values can be given to favor foreground moreflickerSpeed
- a small float multiplier applied to the time in milliseconds; often between 0.0005f and 0.005f
-
putWithReverseConsistentLight
public void putWithReverseConsistentLight(int x, int y, char c, com.badlogic.gdx.graphics.Color foreground, com.badlogic.gdx.graphics.Color background, com.badlogic.gdx.graphics.Color lightColor, double lightAmount, float flickerSpeed)A convenience method that handles blending the background color with a specified light color, by a specific amount, without putting a char on the screen; as a whole this affects one x,y position. This will use the same brightness for all cells given identical lightAmount values when this is called; this differentiates it fromputWithLight(int, int, float, float, float, Noise.Noise3D)
, which would light "splotches" of map with brighter or darker color. Instead, if lightAmount is obtained via SquidLib'sFOV
class, then all cells at a short distance from an FOV center will be lit brightly and cells far away will flicker in and out of view.- Parameters:
x
- the x position, in cellsy
- the y position, in cellsc
- the char to draw; may be'\0'
to draw a solid blockforeground
- the "base" color to use for the foreground, which will be combined with lightColor, as a libGDX Colorbackground
- the "base" color to use for the background, which will used without modificationlightColor
- the color to mix with the foreground, as a libGDX ColorlightAmount
- a double that determines how much lightColor should affect foreground by; not strictly limited to between 0 and 1, and negative values can be given to favor foreground moreflickerSpeed
- a small float multiplier applied to the time in milliseconds; often between 0.0005f and 0.005f
-
putWithLight
A convenience method that handles blending the background color with a specified light color, by a specific amount, without putting a char on the screen; as a whole this affects one x,y position.- Parameters:
x
- the x position, in cellsy
- the y position, in cellsbackground
- the "base" color to use for the background, which will be combined with lightColor, as a packed floatlightColor
- the color to mix with the background, as a packed floatlightAmount
- a float that determines how much lightColor should affect background by; not strictly limited to between 0 and 1, and negative values can be given to favor background more
-
putWithLight
A convenience method that handles blending the background color with a specified light color, by a specific amount, without putting a char on the screen; as a whole this affects one x,y position.- Parameters:
x
- the x position, in cellsy
- the y position, in cellsbackground
- the "base" color to use for the background, which will be combined with lightColor, as a packed floatlightColor
- the color to mix with the background, as a packed floatlightAmount
- a double that determines how much lightColor should affect background by; not strictly limited to between 0 and 1, and negative values can be given to favor background more
-
putWithLight
public void putWithLight(int x, int y, char c, float foreground, float background, float lightColor, float lightAmount)A convenience method that handles blending the background color with a specified light color, by a specific amount, while also putting a char on the screen; as a whole this affects one x,y position.- Parameters:
x
- the x position, in cellsy
- the y position, in cellsc
- the char to put in the foregroundforeground
- the color to use for the foreground, as a packed float; if 0f, this won't place a foreground charbackground
- the "base" color to use for the background, which will be combined with lightColor, as a packed floatlightColor
- the color to mix with the background, as a packed floatlightAmount
- a float that determines how much lightColor should affect background by; not strictly limited to between 0 and 1, and negative values can be given to favor background more
-
putWithLight
public void putWithLight(int x, int y, char c, float foreground, float background, float lightColor, double lightAmount)A convenience method that handles blending the background color with a specified light color, by a specific amount, while also putting a char on the screen; as a whole this affects one x,y position.- Parameters:
x
- the x position, in cellsy
- the y position, in cellsc
- the char to put in the foregroundforeground
- the color to use for the foreground, as a packed float; if 0f, this won't place a foreground charbackground
- the "base" color to use for the background, which will be combined with lightColor, as a packed floatlightColor
- the color to mix with the background, as a packed floatlightAmount
- a double that determines how much lightColor should affect background by; not strictly limited to between 0 and 1, and negative values can be given to favor background more
-
putWithReverseLight
public void putWithReverseLight(int x, int y, char c, float foreground, float background, float lightColor, float lightAmount)A convenience method that handles blending the background color with a specified light color, by a specific amount, while also putting a char on the screen; as a whole this affects one x,y position.- Parameters:
x
- the x position, in cellsy
- the y position, in cellsc
- the char to put in the foregroundforeground
- the color to use for the foreground, as a packed float; if 0f, this won't place a foreground charbackground
- the "base" color to use for the background, which will be combined with lightColor, as a packed floatlightColor
- the color to mix with the background, as a packed floatlightAmount
- a float that determines how much lightColor should affect background by; not strictly limited to between 0 and 1, and negative values can be given to favor background more
-
putWithReverseLight
public void putWithReverseLight(int x, int y, char c, float foreground, float background, float lightColor, double lightAmount)A convenience method that handles blending the background color with a specified light color, by a specific amount, while also putting a char on the screen; as a whole this affects one x,y position.- Parameters:
x
- the x position, in cellsy
- the y position, in cellsc
- the char to put in the foregroundforeground
- the color to use for the foreground, as a packed float; if 0f, this won't place a foreground charbackground
- the "base" color to use for the background, which will be combined with lightColor, as a packed floatlightColor
- the color to mix with the background, as a packed floatlightAmount
- a double that determines how much lightColor should affect background by; not strictly limited to between 0 and 1, and negative values can be given to favor background more
-
putWithLight
public void putWithLight(int x, int y, com.badlogic.gdx.graphics.Color background, com.badlogic.gdx.graphics.Color lightColor, float lightAmount, Noise.Noise3D flicker)A convenience method that handles blending the background color with a specified light color, by a specific amount that will be adjusted by the givenNoise.Noise3D
object, without putting a char on the screen; as a whole this affects one x,y position and will change what it puts as the time (in milliseconds) changes. Ifflicker
is null, this will default to usingWhirlingNoise
. You can make the lighting dimmer by using a darker color forlightColor
or by giving a lower value forlightAmount
.- Parameters:
x
- the x position, in cellsy
- the y position, in cellsbackground
- the "base" color to use for the background, which will be combined with lightColor, as a libGDX ColorlightColor
- the color to mix with the background, as a libGDX ColorlightAmount
- a float that determines how much lightColor should affect background by; not strictly limited to between 0 and 1, and negative values can be given to favor background moreflicker
- a Noise.Noise3D instance, such asWhirlingNoise.instance
; may be null to use WhirlingNoise
-
putWithLight
public void putWithLight(int x, int y, char c, com.badlogic.gdx.graphics.Color foreground, com.badlogic.gdx.graphics.Color background, com.badlogic.gdx.graphics.Color lightColor, float lightAmount, Noise.Noise3D flicker)A convenience method that handles blending the background color with a specified light color, by a specific amount that will be adjusted by the givenNoise.Noise3D
object, while also putting a char on the screen; as a whole this affects one x,y position and will change what it puts as the time (in milliseconds) changes. Ifflicker
is null, this will default to usingWhirlingNoise
. You can make the lighting dimmer by using a darker color forlightColor
or by giving a lower value forlightAmount
.- Parameters:
x
- the x position, in cellsy
- the y position, in cellsc
- the char to put in the foregroundforeground
- the color to use for the foreground, as a libGDX Color; if null, this won't place a foreground charbackground
- the "base" color to use for the background, which will be combined with lightColor, as a libGDX ColorlightColor
- the color to mix with the background, as a libGDX ColorlightAmount
- a float that determines how much lightColor should affect background by; not strictly limited to between 0 and 1, and negative values can be given to favor background moreflicker
- a Noise.Noise3D instance, such asWhirlingNoise.instance
; may be null to use WhirlingNoise
-
putWithLight
public void putWithLight(int x, int y, float background, float lightColor, float lightAmount, Noise.Noise3D flicker)A convenience method that handles blending the background color with a specified light color, by a specific amount that will be adjusted by the givenNoise.Noise3D
object, without putting a char on the screen; as a whole this affects one x,y position and will change what it puts as the time (in milliseconds) changes. Ifflicker
is null, this will default to usingWhirlingNoise
. You can make the lighting dimmer by using a darker color forlightColor
or by giving a lower value forlightAmount
.- Parameters:
x
- the x position, in cellsy
- the y position, in cellsbackground
- the "base" color to use for the background, which will be combined with lightColor, as a packed float colorlightColor
- the color to mix with the background, as a packed float colorlightAmount
- a float that determines how much lightColor should affect background by; not strictly limited to between 0 and 1, and negative values can be given to favor background moreflicker
- a Noise.Noise3D instance, such asWhirlingNoise.instance
; may be null to use WhirlingNoise
-
putWithLight
public void putWithLight(int x, int y, char c, float foreground, float background, float lightColor, float lightAmount, Noise.Noise3D flicker)A convenience method that handles blending the background color with a specified light color, by a specific amount that will be adjusted by the givenNoise.Noise3D
object, while also putting a char on the screen; as a whole this affects one x,y position and will change what it puts as the time (in milliseconds) changes. Ifflicker
is null, this will default to usingWhirlingNoise
. You can make the lighting dimmer by using a darker color forlightColor
or by giving a lower value forlightAmount
.- Parameters:
x
- the x position, in cellsy
- the y position, in cellsc
- the char to put in the foregroundforeground
- the color to use for the foreground, as a packed float; if 0f, this won't place a foreground charbackground
- the "base" color to use for the background, which will be combined with lightColor, as a packed float colorlightColor
- the color to mix with the background, as a packed float colorlightAmount
- a float that determines how much lightColor should affect background by; not strictly limited to between 0 and 1, and negative values can be given to favor background moreflicker
- a Noise.Noise3D instance, such asWhirlingNoise.instance
; may be null to use WhirlingNoise
-
putBorders
-
putBordersCaptioned
public void putBordersCaptioned(float color, IColoredString<com.badlogic.gdx.graphics.Color> caption)- Parameters:
color
- the color to draw the borders with; does not affect caption's color(s)caption
- an IColoredString
-
clear
Removes the foreground chars, where present, in all layers at the given x,y position. The backgrounds will be unchanged.- Specified by:
clear
in interfaceIPackedColorPanel
- Parameters:
x
- the x-coordinate of the position to remove all chars fromy
- the y-coordinate of the position to remove all chars from
-
clear
Removes the foreground char, if present, in the given layer at the given x,y position. The backgrounds and other layers will be unchanged.- Parameters:
x
- the x-coordinate of the position to remove all chars fromy
- the y-coordinate of the position to remove all chars fromlayer
- the layer to remove from
-
clear
Removes all background colors, setting them to transparent, and all foreground chars in all layers.- Overrides:
clear
in classcom.badlogic.gdx.scenes.scene2d.Actor
-
clear
Removes all foreground chars in the requested layer; does not affect the background or other layers. -
fillBackground
Fills all of the background with the given color as libGDX Color object.- Parameters:
color
- the color to use for all of the background, as a libGDX Color or some subclass like SColor
-
fillBackground
Fills all of the background with the given color as a packed float.- Parameters:
color
- the color to use for all of the background, as a packed float
-
fillArea
Changes the background color in an area to all have the given color, as a libGDX Color (or SColor, etc.).- Parameters:
color
- a libGDX Color to fill the area with; may be null to make the background transparentx
- left edge's x coordinate, in cellsy
- top edge's y coordinate, in cellswidth
- the width of the area to change the color onheight
- the height of the area to change the color on
-
fillArea
Changes the background color in an area to all have the given color, as a packed float.- Parameters:
color
- a color as a packed float to fill the area with; may be 0f to make the background transparentx
- left edge's x coordinate, in cellsy
- top edge's y coordinate, in cellswidth
- the width of the area to change the color onheight
- the height of the area to change the color on
-
hasActiveAnimations
Gets whether any animations or other scene2d Actions are running on this SparseLayers.- Specified by:
hasActiveAnimations
in interfaceIPackedColorPanel
- Returns:
- true if any animations or Actions are currently running, false otherwise
-
getBackgrounds
Gets a direct reference to the 2D float array this uses for background colors.- Returns:
- a direct reference to the 2D float array this uses for background colors.
-
setBackgrounds
Changes the reference this uses for the float array for background colors; this will not accept null parameters, nor will it accept any 2D array with dimensions that do not match the (unchanging) gridWidth and gridHeight of this SparseLayers.- Parameters:
backgrounds
- a non-null 2D float array of colors; must have width == gridWidth and height == gridHeight
-
getFont
Gets a direct reference to the TextCellFactory this uses to draw and size its text items and cells.- Returns:
- a direct reference to the TextCellFactory this uses to draw and size its text items and cells.
-
setFont
Sets the TextCellFactory this uses to draw and size its text items and cells. The given TextCellFactory must not be null. If font is uninitialized, this will initialize it using cellWidth and cellHeight. If font has been initialized with a different height and width, then the sizing of this SparseLayers will change.- Parameters:
font
- a non-null TextCellFactory; if uninitialized, this will initialize it using cellWidth and cellHeight.
-
getScc
Gets the IColorCenter for Color objects (almost always a SquidColorCenter, but this isn't guaranteed) that this uses to cache and possibly alter Colors that given to it as parameters.- Returns:
- the IColorCenter of Color that this uses to cache and modify Colors given to it
-
setScc
Sets the IColorCenter for Color objects that this uses to cache and modify Colors given to it; does not accept null parameters.- Parameters:
scc
- a non-null IColorCenter of Color that this will use to cache and modify Colors given to it
-
worldX
Used internally to go between grid positions and world positions.- Parameters:
gridX
- x on the grid- Returns:
- x in the world
-
worldY
Used internally to go between grid positions and world positions.- Parameters:
gridY
- y on the grid- Returns:
- y in the world
-
gridX
Used internally to go between world positions and grid positions.- Parameters:
worldX
- x in the world- Returns:
- x on the grid
-
gridY
Used internally to go between world positions and grid positions.- Parameters:
worldY
- y in the world- Returns:
- y on the grid
-
blend
Using the existing background color at the position x,y, this performs color blending from that existing color to the given color (as a float), using the mixBy parameter to determine how much of the color parameter to use (1f will set the color in this to the parameter, while 0f for mixBy will ignore the color parameter entirely).- Specified by:
blend
in interfaceIPackedColorPanel
- Parameters:
x
- the x component of the position in this panel to draw the starting color fromy
- the y component of the position in this panel to draw the starting color fromcolor
- the new color to mix with the starting color; a packed float, as made byColor.toFloatBits()
mixBy
- the amount by which the new color will affect the old one, between 0 (no effect) and 1 (overwrite)
-
glyph
public TextCellFactory.Glyph glyph(char shown, com.badlogic.gdx.graphics.Color color, int x, int y)Produces a single char with a color, that can be positioned independently of the contents of this SparseLayers. Various effects in this class take a Glyph parameter and can perform visual effects with one. This takes a char to show, a color that may be filtered, and an x,y position in grid cells, and returns a Glyph that has those qualities set.- Parameters:
shown
- the char to use in the Glyphcolor
- the color to use for the Glyph, which can be filteredx
- the x position, in grid cellsy
- the y position, in grid cells- Returns:
- a Glyph (an inner class of TextCellFactory) with the given qualities
-
glyph
Produces a single char with a color, that can be positioned independently of the contents of this SparseLayers. Various effects in this class take a Glyph parameter and can perform visual effects with one. This takes a char to show, a color as an encoded float, and an x,y position in grid cells, and returns a Glyph that has those qualities set.- Parameters:
shown
- the char to use in the Glyphcolor
- the color to use for the Glyph as an encoded floatx
- the x position, in grid cellsy
- the y position, in grid cells- Returns:
- a Glyph (an inner class of TextCellFactory) with the given qualities
-
glyphFromGrid
"Promotes" a colorful char in the first layer to a Glyph that can be positioned independently of the contents of this SparseLayers. Various effects in this class take a Glyph parameter and can perform visual effects with one. This takes only an x,y position in grid cells, removes the char at that position in the first layer from normal rendering, and returns a Glyph at that same position with the same char and color, but that can be moved more.- Parameters:
x
- the x position, in grid cellsy
- the y position, in grid cells- Returns:
- a Glyph (an inner class of TextCellFactory) that took the qualities of the removed char and its color
-
glyphFromGrid
"Promotes" a colorful char in the given layer to a Glyph that can be positioned independently of the contents of this SparseLayers. Various effects in this class take a Glyph parameter and can perform visual effects with one. This takes only an x,y position in grid cells, removes the char at that position in the given layer from normal rendering, and returns a Glyph at that same position with the same char and color, but that can be moved more.- Parameters:
x
- the x position, in grid cellsy
- the y position, in grid cellslayer
- the layer to take a colorful char from- Returns:
- a Glyph (an inner class of TextCellFactory) that took the qualities of the removed char and its color; may return null if the layer is invalid
-
recallToGrid
Brings a Glyph back into normal rendering, removing it from the Glyphs this class knows about and filling the grid's char at the Glyph's position in the first layer with the Glyph's char and color.- Parameters:
glyph
- the Glyph to remove and fit back into the grid
-
recallToGrid
Brings a Glyph back into normal rendering, removing it from the Glyphs this class knows about and filling the grid's char at the Glyph's position in the given layer with the Glyph's char and color.- Parameters:
glyph
- the Glyph to remove and fit back into the grid
-
removeGlyph
A way to remove a Glyph from the group of glyphs this renders, while also ending any animations or other Actions that the removed Glyph was scheduled to perform.- Parameters:
glyph
- a Glyph that should be removed from theglyphs
List this holds
-
bump
Start a bumping animation in the given direction that will last duration seconds.- Parameters:
glyph
- ATextCellFactory.Glyph
, probably produced byglyph(char, float, int, int)
orglyphFromGrid(int, int)
direction
- the direction for the glyph to bump towardsduration
- a float, measured in seconds, for how long the animation should last; commonly 0.12f
-
bump
public void bump(float delay, TextCellFactory.Glyph glyph, Direction direction, float duration, Runnable postRunnable)Start a bumping animation in the given direction after delay seconds, that will last duration seconds; runs postRunnable after the duration completes if postRunnable is non-null.- Parameters:
delay
- how long to wait in seconds before starting the effectglyph
- ATextCellFactory.Glyph
, which should be produced by a SparseLayers method likeglyph(char, float, int, int)
orglyphFromGrid(int, int)
direction
- the direction for the glyph to bump towardsduration
- a float, measured in seconds, for how long the animation should last; commonly 0.12fpostRunnable
- a Runnable to execute after the bump completes; may be null to do nothing.
-
slide
public void slide(TextCellFactory.Glyph glyph, int startX, int startY, int newX, int newY, float duration, Runnable postRunnable)Slidesglyph
from(xstartX,startY)
to(newx, newy)
. Takes a number of seconds equal to duration to complete. This also allows a Runnable to be given aspostRunnable
to be run after the slide completes, or null to not run anything after the slide.- Parameters:
glyph
- ATextCellFactory.Glyph
, probably produced byglyph(char, float, int, int)
orglyphFromGrid(int, int)
startX
- Where to start the slide, horizontally.startY
- Where to start the slide, vertically.newX
- Where to end the slide, horizontally.newY
- Where to end the slide, vertically.duration
- The animation's duration.postRunnable
- a Runnable to execute after the slide completes; may be null to do nothing.
-
slide
public void slide(float delay, TextCellFactory.Glyph glyph, int startX, int startY, int newX, int newY, float duration, Runnable postRunnable)Slidesglyph
from(xstartX,startY)
to(newx, newy)
after waitingdelay
seconds. Takes a number of seconds equal to duration to complete (starting after the delay). This also allows a Runnable to be given aspostRunnable
to be run after the slide completes, or null to not run anything after the slide.- Parameters:
delay
- how long to wait in seconds before starting the effectglyph
- ATextCellFactory.Glyph
, probably produced byglyph(char, float, int, int)
orglyphFromGrid(int, int)
startX
- Where to start the slide, horizontally.startY
- Where to start the slide, vertically.newX
- Where to end the slide, horizontally.newY
- Where to end the slide, vertically.duration
- The animation's duration.postRunnable
- a Runnable to execute after the slide completes; may be null to do nothing.
-
wiggle
Starts an wiggling animation for the object at the given location for the given duration in seconds.- Parameters:
glyph
- ATextCellFactory.Glyph
, probably produced byglyph(char, float, int, int)
orglyphFromGrid(int, int)
duration
- in seconds, as a float
-
wiggle
public void wiggle(float delay, TextCellFactory.Glyph glyph, float duration, Runnable postRunnable)Starts a wiggling animation for the object at the given location, after waiting delay seconds, for the given duration in seconds; runs postRunnable afterwards if it is non-null.- Parameters:
delay
- how long to wait in seconds before starting the effectglyph
- ATextCellFactory.Glyph
, probably produced byglyph(char, float, int, int)
orglyphFromGrid(int, int)
duration
- in seconds, as a floatpostRunnable
- a Runnable to execute after the wiggle completes; may be null to do nothing.
-
tint
Tints the background at position x,y so it becomes the given encodedColor, then after the tint is complete it returns the cell to its original color, taking duration seconds.
This will only behave correctly if you callStage.act()
before you callStage.draw()
, but after any changes to the contents of this SparseLayers. If you change the contents, then draw, and then act, that will draw the contents without the tint this applies, then apply the tint when you call act(), then quickly overwrite the tint in the next frame. That visually appears as nothing happening other than a delay.- Parameters:
x
- the x-coordinate of the cell to tinty
- the y-coordinate of the cell to tintcolor
- what to transition the cell's color towards, and then transition back from, as a Color objectduration
- how long the total "round-trip" transition should take in seconds
-
tint
Tints the background at position x,y so it becomes the given encodedColor, then after the tint is complete it returns the cell to its original color, taking duration seconds.
This will only behave correctly if you callStage.act()
before you callStage.draw()
, but after any changes to the contents of this SparseLayers. If you change the contents, then draw, and then act, that will draw the contents without the tint this applies, then apply the tint when you call act(), then quickly overwrite the tint in the next frame. That visually appears as nothing happening other than a delay.- Parameters:
x
- the x-coordinate of the cell to tinty
- the y-coordinate of the cell to tintencodedColor
- what to transition the cell's color towards, and then transition back from, as a packed floatduration
- how long the total "round-trip" transition should take in seconds
-
tint
public void tint(float delay, int x, int y, float encodedColor, float duration, Runnable postRunnable)Tints the background at position x,y so it becomes the given encodedColor, waiting fordelay
(in seconds) before performing it, then after the tint is complete it returns the cell to its original color, taking duration seconds. Additionally, enqueuepostRunnable
for running after the created action ends.
This will only behave correctly if you callStage.act()
before you callStage.draw()
, but after any changes to the contents of this SparseLayers. If you change the contents, then draw, and then act, that will draw the contents without the tint this applies, then apply the tint when you call act(), then quickly overwrite the tint in the next frame. That visually appears as nothing happening other than a delay.- Parameters:
delay
- how long to wait in seconds before starting the effectx
- the x-coordinate of the cell to tinty
- the y-coordinate of the cell to tintencodedColor
- what to transition the cell's color towards, and then transition back from, as a packed floatduration
- how long the total "round-trip" transition should take in secondspostRunnable
- a Runnable to execute after the tint completes; may be null to do nothing.
-
tint
Tints the foreground in the given layer at position x,y so it becomes the given encodedColor, then after the tint is complete it returns the cell to its original color, taking duration seconds.
TheSquidPanel.tint(float, int, int, Color, float, Runnable)
method has been reworked to use the same technique this class uses for rendering text, and the two classes should have similar appearance (if not the same) when rendering the same text. SparseLayers tends to be faster, especially when not all of the map is shown.
This will only behave correctly if you callStage.act()
before you callStage.draw()
, but after any changes to the contents of this SparseLayers. If you change the contents, then draw, and then act, that will draw the contents without the tint this applies, then apply the tint when you call act(), then quickly overwrite the tint in the next frame. That visually appears as nothing happening other than a delay.- Parameters:
x
- the x-coordinate of the cell to tinty
- the y-coordinate of the cell to tintlayer
- which layer to affect; if you haven't specified a layer when placing text, then this should be 0color
- what to transition the cell's color towards, and then transition back from, as a Color objectduration
- how long the total "round-trip" transition should take in seconds
-
tint
Tints the foreground in the given layer at position x,y so it becomes the given encodedColor, then after the tint is complete it returns the cell to its original color, taking duration seconds.
TheSquidPanel.tint(float, int, int, Color, float, Runnable)
method has been reworked to use the same technique this class uses for rendering text, and the two classes should have similar appearance (if not the same) when rendering the same text. SparseLayers tends to be faster, especially when not all of the map is shown.
This will only behave correctly if you callStage.act()
before you callStage.draw()
, but after any changes to the contents of this SparseLayers. If you change the contents, then draw, and then act, that will draw the contents without the tint this applies, then apply the tint when you call act(), then quickly overwrite the tint in the next frame. That visually appears as nothing happening other than a delay.- Parameters:
x
- the x-coordinate of the cell to tinty
- the y-coordinate of the cell to tintlayer
- which layer to affect; if you haven't specified a layer when placing text, then this should be 0encodedColor
- what to transition the cell's color towards, and then transition back from, as a packed floatduration
- how long the total "round-trip" transition should take in seconds
-
tint
public void tint(float delay, int x, int y, int layer, float encodedColor, float duration, Runnable postRunnable)Tints the foreground in the given layer at position x,y so it becomes the given encodedColor, waiting fordelay
(in seconds) before performing it, then after the tint is complete it returns the cell to its original color, taking duration seconds. Additionally, enqueuepostRunnable
for running after the created action ends.
TheSquidPanel.tint(float, int, int, Color, float, Runnable)
method has been reworked to use the same technique this class uses for rendering text, and the two classes should have similar appearance (if not the same) when rendering the same text. SparseLayers tends to be faster, especially when not all of the map is shown.
This will only behave correctly if you callStage.act()
before you callStage.draw()
, but after any changes to the contents of this SparseLayers. If you change the contents, then draw, and then act, that will draw the contents without the tint this applies, then apply the tint when you call act(), then quickly overwrite the tint in the next frame. That visually appears as nothing happening other than a delay.- Parameters:
delay
- how long to wait in seconds before starting the effectx
- the x-coordinate of the cell to tinty
- the y-coordinate of the cell to tintlayer
- which layer to affect; if you haven't specified a layer when placing text, then this should be 0encodedColor
- what to transition the cell's color towards, and then transition back from, as a packed floatduration
- how long the total "round-trip" transition should take in secondspostRunnable
- a Runnable to execute after the tint completes; may be null to do nothing.
-
tint
Tints the given glyph (which may or may not be part of theglyphs
list this holds) so it becomes the given encodedColor, then after the tint is complete it returns the cell to its original color, taking duration seconds. This resets the glyph to its pre-tint color before it ends.- Parameters:
glyph
- theTextCellFactory.Glyph
to tintencodedColor
- what to transition the cell's color towards, and then transition back from, as a packed floatduration
- how long the total "round-trip" transition should take in seconds
-
tint
public void tint(float delay, TextCellFactory.Glyph glyph, float encodedColor, float duration, Runnable postRunnable)Tints the given glyph (which may or may not be part of theglyphs
list this holds) so it becomes the given encodedColor, waiting fordelay
(in seconds) before performing it, then after the tint is complete it returns the cell to its original color, taking duration seconds. Additionally, enqueuepostRunnable
for running after the created action ends. This resets the glyph to its pre-tint color before it runs anypostRunnable
.- Parameters:
delay
- how long to wait in seconds before starting the effectglyph
- theTextCellFactory.Glyph
to tintencodedColor
- what to transition the cell's color towards, and then transition back from, as a packed floatduration
- how long the total "round-trip" transition should take in secondspostRunnable
- a Runnable to execute after the tint completes; may be null to do nothing.
-
summon
public void summon(int startX, int startY, int endX, int endY, char shown, float startColor, float endColor, float duration)Create a new Glyph at (startX, startY) using the char shown with the given startColor, and immediately starts changing color to endColor, changing position so it ends on the cell (endX, endY), taking duration seconds to complete before removing the Glyph.
UnlikeSquidPanel.summon(float, int, int, int, int, char, Color, Color, boolean, float, float, float)
, this does not rotate the Glyph it produces.- Parameters:
startX
- the starting x position in cellsstartY
- the starting y position in cellsendX
- the ending x position in cellsendY
- the ending y position in cellsshown
- the char to show (the same char throughout the effect)startColor
- the starting ColorendColor
- the Color to transition toduration
- the duration in seconds for the effect
-
summon
public void summon(float delay, int startX, int startY, int endX, int endY, char shown, float startColor, float endColor, float duration, Runnable postRunnable)Create a new Glyph at (startX, startY) using the char shown with the given startColor, and after delay seconds, starts changing color to endColor, changing position so it ends on the cell (endX, endY), taking duration seconds to complete before running postRunnable (if it is non-null) and finally removing the Glyph.
UnlikeSquidPanel.summon(float, int, int, int, int, char, Color, Color, boolean, float, float, float)
, this does not rotate the Glyph it produces.- Parameters:
delay
- how long to wait in seconds before starting the effectstartX
- the starting x position in cellsstartY
- the starting y position in cellsendX
- the ending x position in cellsendY
- the ending y position in cellsshown
- the char to show (the same char throughout the effect)startColor
- the starting ColorendColor
- the Color to transition toduration
- the duration in seconds for the effectpostRunnable
- a Runnable to execute after the summon completes; may be null to do nothing.
-
summon
public void summon(float startX, float startY, float endX, float endY, char shown, float startColor, float endColor, float duration)Create a new Glyph at (startX, startY) in world coordinates (often pixels on the screen) using the char shown with the given startColor, and immediately starts changing color to endColor, changing position so it ends at the world coordinates (endX, endY), taking duration seconds to complete before removing the Glyph.
UnlikeSquidPanel.summon(float, int, int, int, int, char, Color, Color, boolean, float, float, float)
, this does not rotate the Glyph it produces.- Parameters:
startX
- the starting x position in world coordinatesstartY
- the starting y position in world coordinatesendX
- the ending x position in world coordinatesendY
- the ending y position in world coordinatesshown
- the char to show (the same char throughout the effect)startColor
- the starting ColorendColor
- the Color to transition toduration
- the duration in seconds for the effect
-
summon
public void summon(float delay, float startX, float startY, float endX, float endY, char shown, float startColor, float endColor, float duration, Runnable postRunnable)Create a new Glyph at (startX, startY) in world coordinates (often pixels on the screen) using the char shown with the given startColor, and after delay seconds, starts changing color to endColor, changing position so it ends at the world coordinates (endX, endY), taking duration seconds to complete before running postRunnable (if it is non-null) and finally removing the Glyph.
UnlikeSquidPanel.summon(float, int, int, int, int, char, Color, Color, boolean, float, float, float)
, this does not rotate the Glyph it produces.- Parameters:
delay
- how long to wait in seconds before starting the effectstartX
- the starting x position in world coordinatesstartY
- the starting y position in world coordinatesendX
- the ending x position in world coordinatesendY
- the ending y position in world coordinatesshown
- the char to show (the same char throughout the effect)startColor
- the starting ColorendColor
- the Color to transition toduration
- the duration in seconds for the effectpostRunnable
- a Runnable to execute after the summon completes; may be null to do nothing.
-
burst
public void burst(int x, int y, int distance, Radius measurement, char shown, float startColor, float endColor, float duration)Convenience method to produce an explosion, splash, or burst effect. Callssummon(int, int, int, int, char, float, float, float)
repeatedly with different parameters. As with summon(), this creates temporary Glyphs that change color and position. The distance is how many cells away to move the created Actors away from (x,y). The measurement determines whether this produces Glyphs in 4 (cardinal) directions for DIAMOND or OCTAHEDRON, or 8 (cardinal and diagonal) directions for any other enum value for Radius; CIRCLE and SPHERE will position the 8 glyphs in a circle, while SQUARE and CUBE will position their 8 glyphs in a square.
UnlikeSquidPanel.burst(float, int, int, int, boolean, char, Color, Color, boolean, float, float)
, this does not rotate the individual Glyphs it produces.- Parameters:
x
- the starting, center, x-position in cells to create all Actors aty
- the starting, center, y-position in cells to create all Actors atdistance
- how far away, in cells, to move each actor from the center (Chebyshev distance, forming a square)measurement
- a Radius enum that determines if 4 (DIAMOND, OCTAHEDRON) or 8 (anything else) Glyphs are created, and the shape they will takeshown
- the char to use for Glyphs; should definitely be visiblestartColor
- the encoded color to start the effect withendColor
- the encoded color to end the effect onduration
- how long, in seconds, the effect should last
-
burst
public void burst(float delay, int x, int y, int distance, Radius measurement, char shown, float startColor, float endColor, float duration, Runnable postRunnable)Convenience method to produce an explosion, splash, or burst effect. Callssummon(float, int, int, int, int, char, float, float, float, Runnable)
repeatedly with different parameters. As with summon(), this creates temporary Glyphs that change color and position. The distance is how many cells away to move the created Actors away from (x,y). The measurement determines whether this produces Glyphs in 4 (cardinal) directions for DIAMOND or OCTAHEDRON, or 8 (cardinal and diagonal) directions for any other enum value for Radius; CIRCLE and SPHERE will position the 8 glyphs in a circle, while SQUARE and CUBE will position their 8 glyphs in a square. This takes a delay in seconds that can be used to make the effect wait to start for some amount of time, and a Runnable that will be run once after the burst's full duration completes (not once per summoned Glyph).
UnlikeSquidPanel.burst(float, int, int, int, boolean, char, Color, Color, boolean, float, float)
, this does not rotate the individual Glyphs it produces.- Parameters:
delay
- how long to wait in seconds before starting the effectx
- the starting, center, x-position in cells to create all Actors aty
- the starting, center, y-position in cells to create all Actors atdistance
- how far away, in cells, to move each actor from the center (Chebyshev distance, forming a square)measurement
- a Radius enum that determines if 4 (DIAMOND, OCTAHEDRON) or 8 (anything else) Glyphs are created, and the shape they will takeshown
- the char to use for Glyphs; should definitely be visiblestartColor
- the encoded color to start the effect withendColor
- the encoded color to end the effect onduration
- how long, in seconds, the effect should lastpostRunnable
- a Runnable to execute after the burst completes; may be null to do nothing, and will only be run once for the whole burst effect.
-
burst
public void burst(int x, int y, int distance, Radius measurement, CharSequence choices, float startColor, float endColor, float duration)Convenience method to produce an explosion, splash, or burst effect. Callssummon(int, int, int, int, char, float, float, float)
repeatedly with different parameters. As with summon(), this creates temporary Glyphs that change color and position. The distance is how many cells away to move the created Actors away from (x,y). The measurement determines whether this produces Glyphs in 4 (cardinal) directions for DIAMOND or OCTAHEDRON, or 8 (cardinal and diagonal) directions for any other enum value for Radius; CIRCLE and SPHERE will position the 8 glyphs in a circle, while SQUARE and CUBE will position their 8 glyphs in a square.
UnlikeSquidPanel.burst(float, int, int, int, boolean, char, Color, Color, boolean, float, float)
, this does not rotate the individual Glyphs it produces.- Parameters:
x
- the starting, center, x-position in cells to create all Actors aty
- the starting, center, y-position in cells to create all Actors atdistance
- how far away, in cells, to move each actor from the center (Chebyshev distance, forming a square)measurement
- a Radius enum that determines if 4 (DIAMOND, OCTAHEDRON) or 8 (anything else) Glyphs are created, and the shape they will takechoices
- a String or other CharSequence containing the chars this can randomly choosestartColor
- the encoded color to start the effect withendColor
- the encoded color to end the effect onduration
- how long, in seconds, the effect should last
-
burst
public void burst(float delay, int x, int y, int distance, Radius measurement, CharSequence choices, float startColor, float endColor, float duration, Runnable postRunnable)Convenience method to produce an explosion, splash, or burst effect. Callssummon(int, int, int, int, char, float, float, float)
repeatedly with different parameters. As with summon(), this creates temporary Glyphs that change color and position. The distance is how many cells away to move the created Actors away from (x,y). The measurement determines whether this produces Glyphs in 4 (cardinal) directions for DIAMOND or OCTAHEDRON, or 8 (cardinal and diagonal) directions for any other enum value for Radius; CIRCLE and SPHERE will position the 8 glyphs in a circle, while SQUARE and CUBE will position their 8 glyphs in a square. This takes a delay in seconds that can be used to make the effect wait to start for some amount of time, and a Runnable that will be run once after the burst's full duration completes (not once per summoned Glyph).
UnlikeSquidPanel.burst(float, int, int, int, boolean, char, Color, Color, boolean, float, float)
, this does not rotate the individual Glyphs it produces.- Parameters:
delay
- how long to wait in seconds before starting the effectx
- the starting, center, x-position in cells to create all Actors aty
- the starting, center, y-position in cells to create all Actors atdistance
- how far away, in cells, to move each actor from the center (Chebyshev distance, forming a square)measurement
- a Radius enum that determines if 4 (DIAMOND, OCTAHEDRON) or 8 (anything else) Glyphs are created, and the shape they will takechoices
- a String or other CharSequence containing the chars this can randomly choosestartColor
- the encoded color to start the effect withendColor
- the encoded color to end the effect onduration
- how long, in seconds, the effect should lastpostRunnable
- a Runnable to execute after the burst completes; may be null to do nothing, and will only be run once for the whole burst effect.
-
recolor
Changes the background at position x,y so it becomes the given color, taking duration seconds. The background will keep the changed color after the effect, unless drawn over.
This will only behave correctly if you callStage.act()
before you callStage.draw()
, but after any changes to the contents of this SparseLayers. If you change the contents, then draw, and then act, that will draw the contents without the recolor this applies, then apply the recolor when you call act(), then quickly overwrite the recolor in the next frame. That visually appears as nothing happening other than a delay.- Parameters:
x
- the x-coordinate of the cell to recolory
- the y-coordinate of the cell to recolorcolor
- what to gradually change the cell's color to, as a Color objectduration
- how long the total transition should take in seconds
-
recolor
Changes the background at position x,y so it becomes the given encodedColor, taking duration seconds. The background will keep the changed color after the effect, unless drawn over.
This will only behave correctly if you callStage.act()
before you callStage.draw()
, but after any changes to the contents of this SparseLayers. If you change the contents, then draw, and then act, that will draw the contents without the recolor this applies, then apply the recolor when you call act(), then quickly overwrite the recolor in the next frame. That visually appears as nothing happening other than a delay.- Parameters:
x
- the x-coordinate of the cell to recolory
- the y-coordinate of the cell to recolorencodedColor
- what to gradually change the cell's color to, as a packed floatduration
- how long the total transition should take in seconds
-
recolor
Changes the background at position x,y so it becomes the given encodedColor, waiting fordelay
(in seconds) before performing it, taking duration seconds. The background will keep the changed color after the effect, unless drawn over.
This will only behave correctly if you callStage.act()
before you callStage.draw()
, but after any changes to the contents of this SparseLayers. If you change the contents, then draw, and then act, that will draw the contents without the recolor this applies, then apply the recolor when you call act(), then quickly overwrite the recolor in the next frame. That visually appears as nothing happening other than a delay.- Parameters:
delay
- how long to wait in seconds before starting the effectx
- the x-coordinate of the cell to recolory
- the y-coordinate of the cell to recolorencodedColor
- what to gradually change the cell's color to, as a packed floatduration
- how long the total transition should take in seconds
-
recolor
public void recolor(float delay, int x, int y, float encodedColor, float duration, Runnable postRunnable)Changes the background at position x,y so it becomes the given encodedColor, waiting fordelay
(in seconds) before performing it, taking duration seconds. The background will keep the changed color after the effect, unless drawn over. Additionally, enqueuepostRunnable
for running after the created action ends.
This will only behave correctly if you callStage.act()
before you callStage.draw()
, but after any changes to the contents of this SparseLayers. If you change the contents, then draw, and then act, that will draw the contents without the recolor this applies, then apply the recolor when you call act(), then quickly overwrite the recolor in the next frame. That visually appears as nothing happening other than a delay.- Parameters:
delay
- how long to wait in seconds before starting the effectx
- the x-coordinate of the cell to recolory
- the y-coordinate of the cell to recolorencodedColor
- what to gradually change the cell's color to, as a packed floatduration
- how long the total transition should take in secondspostRunnable
- a Runnable to execute after the recolor completes; may be null to do nothing.
-
recolor
public void recolor(int x, int y, int layer, com.badlogic.gdx.graphics.Color color, float duration)Changes the foreground in the given layer at position x,y so it becomes the given color, taking duration seconds. The foreground color will keep the changed color after the effect, unless drawn over.
This will only behave correctly if you callStage.act()
before you callStage.draw()
, but after any changes to the contents of this SparseLayers. If you change the contents, then draw, and then act, that will draw the contents without the recolor this applies, then apply the recolor when you call act(), then quickly overwrite the recolor in the next frame. That visually appears as nothing happening other than a delay.- Parameters:
x
- the x-coordinate of the cell to recolory
- the y-coordinate of the cell to recolorlayer
- which layer to affect; if you haven't specified a layer when placing text, then this should be 0color
- what to gradually change the cell's color to, as a Color objectduration
- how long the total transition should take in seconds
-
recolor
Changes the foreground in the given layer at position x,y so it becomes the given encodedColor, taking duration seconds. The foreground color will keep the changed color after the effect, unless drawn over.
This will only behave correctly if you callStage.act()
before you callStage.draw()
, but after any changes to the contents of this SparseLayers. If you change the contents, then draw, and then act, that will draw the contents without the recolor this applies, then apply the recolor when you call act(), then quickly overwrite the recolor in the next frame. That visually appears as nothing happening other than a delay.- Parameters:
x
- the x-coordinate of the cell to recolory
- the y-coordinate of the cell to recolorlayer
- which layer to affect; if you haven't specified a layer when placing text, then this should be 0encodedColor
- what to gradually change the cell's color to, as a packed floatduration
- how long the total transition should take in seconds
-
recolor
Changes the foreground in the given layer at position x,y so it becomes the given encodedColor, waiting fordelay
(in seconds) before performing it, taking duration seconds. The foreground color will keep the changed color after the effect, unless drawn over.
This will only behave correctly if you callStage.act()
before you callStage.draw()
, but after any changes to the contents of this SparseLayers. If you change the contents, then draw, and then act, that will draw the contents without the recolor this applies, then apply the recolor when you call act(), then quickly overwrite the recolor in the next frame. That visually appears as nothing happening other than a delay.- Parameters:
delay
- how long to wait in seconds before starting the effectx
- the x-coordinate of the cell to recolory
- the y-coordinate of the cell to recolorlayer
- which layer to affect; if you haven't specified a layer when placing text, then this should be 0encodedColor
- what to gradually change the cell's color to, as a packed floatduration
- how long the total transition should take in seconds
-
recolor
public void recolor(float delay, int x, int y, int layer, float encodedColor, float duration, Runnable postRunnable)Changes the foreground in the given layer at position x,y so it becomes the given encodedColor, waiting fordelay
(in seconds) before performing it, taking duration seconds. The foreground color will keep the changed color after the effect, unless drawn over. Additionally, enqueuepostRunnable
for running after the created action ends.
This will only behave correctly if you callStage.act()
before you callStage.draw()
, but after any changes to the contents of this SparseLayers. If you change the contents, then draw, and then act, that will draw the contents without the recolor this applies, then apply the recolor when you call act(), then quickly overwrite the recolor in the next frame. That visually appears as nothing happening other than a delay.- Parameters:
delay
- how long to wait in seconds before starting the effectx
- the x-coordinate of the cell to recolory
- the y-coordinate of the cell to recolorlayer
- which layer to affect; if you haven't specified a layer when placing text, then this should be 0encodedColor
- what to gradually change the cell's color to, as a packed floatduration
- how long the total transition should take in secondspostRunnable
- a Runnable to execute after the recolor completes; may be null to do nothing.
-
draw
Draws the SparseLayers and all glyphs it tracks.Batch.begin()
must have already been called on the batch, andBatch.end()
should be called after this returns and before the rendering code finishes for the frame.
This will set the shader ofbatch
if using a distance field or MSDF font and the shader is currently not configured for such a font; it does not reset the shader to the default so that multiple Actors can all use the same shader and so specific extra glyphs or other items can be rendered after calling draw(). If you need to draw both a distance field font and full-color art, you should set the shader on the Batch to null when you want to draw full-color art, and end the Batch between drawing this object and the other art.- Overrides:
draw
in classcom.badlogic.gdx.scenes.scene2d.Actor
- Parameters:
batch
- a Batch such as aFilterBatch
that must be between a begin() and end() call; usually done by StageparentAlpha
- currently ignored
-