Package squidpony.squidgrid.gui.gdx
Class SquidPanel
java.lang.Object
com.badlogic.gdx.scenes.scene2d.Actor
com.badlogic.gdx.scenes.scene2d.Group
squidpony.squidgrid.gui.gdx.SquidPanel
- All Implemented Interfaces:
com.badlogic.gdx.scenes.scene2d.utils.Cullable
,IPackedColorPanel
- Direct Known Subclasses:
ImageSquidPanel
public class SquidPanel extends com.badlogic.gdx.scenes.scene2d.Group implements IPackedColorPanel
Displays text and images in a grid pattern. Supports basic animations.
Grid width and height settings are in terms of number of cells. Cell width and height
are in terms of number of pixels.
When text is placed, the background color is set separately from the foreground character. When moved, only the
foreground character is moved.
- Author:
- Eben Howard - http://squidpony.com - howard@squidpony.com
-
Field Summary
Fields Modifier and Type Field Description OrderedSet<AnimatedEntity>
animatedEntities
protected int
animationCount
OrderedSet<com.badlogic.gdx.scenes.scene2d.Actor>
autoActors
protected int
cellHeight
protected int
cellWidth
float[][]
colors
The 2D array of floats representing colors in a way that libGDX can efficiently use, ABGR-packed.char[][]
contents
The 2D array of chars that this will render, using x,y indexing.float
DEFAULT_ANIMATION_DURATION
protected com.badlogic.gdx.graphics.Color
defaultForeground
protected int
gridHeight
protected int
gridOffsetX
protected int
gridOffsetY
protected int
gridWidth
protected com.badlogic.gdx.graphics.Color
lightingColor
protected float
lightingFloat
boolean
onlyRenderEven
For thin-wall maps, where only cells where x and y are both even numbers have backgrounds displayed.protected IColorCenter<com.badlogic.gdx.graphics.Color>
scc
protected TextCellFactory
textFactory
protected com.badlogic.gdx.graphics.Color
tmpColor
protected float
xOffset
protected float
yOffset
-
Constructor Summary
Constructors Constructor Description SquidPanel(int gridWidth, int gridHeight)
Creates a bare-bones panel with all default values for text rendering.SquidPanel(int gridWidth, int gridHeight, int cellWidth, int cellHeight)
Creates a panel with the given grid and cell size.SquidPanel(int gridWidth, int gridHeight, TextCellFactory factory)
Builds a panel with the given grid size and all other parameters determined by the factory.SquidPanel(int gridWidth, int gridHeight, TextCellFactory factory, IColorCenter<com.badlogic.gdx.graphics.Color> center)
Builds a panel with the given grid size and all other parameters determined by the factory.SquidPanel(int gridWidth, int gridHeight, TextCellFactory factory, IColorCenter<com.badlogic.gdx.graphics.Color> center, float xOffset, float yOffset)
Builds a panel with the given grid size and all other parameters determined by the factory.SquidPanel(int gridWidth, int gridHeight, TextCellFactory factory, IColorCenter<com.badlogic.gdx.graphics.Color> center, float xOffset, float yOffset, char[][] actualMap)
Builds a panel with the given grid size and all other parameters determined by the factory. -
Method Summary
Modifier and Type Method Description float
adjustX(float x, boolean doubleWidth)
float
adjustY(float y)
AnimatedEntity
animateActor(int x, int y, boolean doubleWidth, boolean stretch, com.badlogic.gdx.graphics.g2d.TextureRegion texture)
Create an AnimatedEntity at position x, y, using a TextureRegion with no color modifications, which, if and only if stretch is true, will be stretched to fit one cell, or two cells if doubleWidth is true.AnimatedEntity
animateActor(int x, int y, boolean doubleWidth, boolean stretch, com.badlogic.gdx.graphics.g2d.TextureRegion texture, com.badlogic.gdx.graphics.Color color)
Create an AnimatedEntity at position x, y, using a TextureRegion with the given color, which, if and only if stretch is true, will be stretched to fit one cell, or two cells if doubleWidth is true.AnimatedEntity
animateActor(int x, int y, boolean doubleWidth, char c, com.badlogic.gdx.graphics.Color color)
Create an AnimatedEntity at position x, y, using the char c in the given color.AnimatedEntity
animateActor(int x, int y, boolean doubleWidth, com.badlogic.gdx.graphics.g2d.TextureRegion texture)
Create an AnimatedEntity at position x, y, using a TextureRegion with no color modifications, which will be stretched to fit one cell, or two cells if doubleWidth is true.AnimatedEntity
animateActor(int x, int y, boolean doubleWidth, com.badlogic.gdx.graphics.g2d.TextureRegion texture, com.badlogic.gdx.graphics.Color color)
Create an AnimatedEntity at position x, y, using a TextureRegion with the given color, which will be stretched to fit one cell, or two cells if doubleWidth is true.AnimatedEntity
animateActor(int x, int y, boolean doubleWidth, com.badlogic.gdx.graphics.g2d.TextureRegion texture, Collection<com.badlogic.gdx.graphics.Color> colors)
Create an AnimatedEntity at position x, y, using a TextureRegion with the given color, which will be stretched to fit one cell, or two cells if doubleWidth is true.AnimatedEntity
animateActor(int x, int y, boolean doubleWidth, com.badlogic.gdx.graphics.g2d.TextureRegion texture, Collection<com.badlogic.gdx.graphics.Color> colors, float loopTime)
Create an AnimatedEntity at position x, y, using a TextureRegion with the given color, which will be stretched to fit one cell, or two cells if doubleWidth is true.AnimatedEntity
animateActor(int x, int y, boolean doubleWidth, String s, com.badlogic.gdx.graphics.Color color)
Create an AnimatedEntity at position x, y, using the String s in the given color.AnimatedEntity
animateActor(int x, int y, boolean doubleWidth, String s, Collection<com.badlogic.gdx.graphics.Color> colors)
Create an AnimatedEntity at position x, y, using the String s in the given color.AnimatedEntity
animateActor(int x, int y, boolean doubleWidth, String s, Collection<com.badlogic.gdx.graphics.Color> colors, float loopTime)
Create an AnimatedEntity at position x, y, using the String s in the given color.AnimatedEntity
animateActor(int x, int y, char c, com.badlogic.gdx.graphics.Color color)
Create an AnimatedEntity at position x, y, using the char c in the given color.AnimatedEntity
animateActor(int x, int y, com.badlogic.gdx.graphics.g2d.TextureRegion texture)
Create an AnimatedEntity at position x, y, using a TextureRegion with no color modifications, which will be stretched to fit one cell.AnimatedEntity
animateActor(int x, int y, com.badlogic.gdx.graphics.g2d.TextureRegion texture, com.badlogic.gdx.graphics.Color color)
Create an AnimatedEntity at position x, y, using a TextureRegion with the given color, which will be stretched to fit one cell.AnimatedEntity
animateActor(int x, int y, String s, com.badlogic.gdx.graphics.Color color)
Create an AnimatedEntity at position x, y, using the String s in the given color.void
blend(int x, int y, float color, float mixBy)
Using the existing 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(int x, int y, Direction direction)
Starts a bumping animation in the direction provided.void
bump(int x, int y, Direction direction, float duration)
Start a bumping animation in the given direction that will last duration seconds.void
bump(AnimatedEntity ae, Direction direction, float duration)
Start a bumping animation in the given direction that will last duration seconds.void
bump(Coord location, Direction direction)
Starts a bumping animation in the direction provided.void
burst(float delay, int x, int y, int distance, boolean eightWay, char glyph, com.badlogic.gdx.graphics.Color startColor, com.badlogic.gdx.graphics.Color endColor, boolean doubleWidth, float rotationStrength, float duration)
Convenience method to produce an explosion, splash, or burst effect.void
burst(int x, int y, boolean eightWay, char glyph, com.badlogic.gdx.graphics.Color startColor, float duration)
Convenience method to produce an explosion, splash, or burst effect.void
burst(int x, int y, boolean eightWay, char glyph, com.badlogic.gdx.graphics.Color startColor, com.badlogic.gdx.graphics.Color endColor, boolean doubleWidth, float rotationStrength, float duration)
Convenience method to produce an explosion, splash, or burst effect.void
burst(int x, int y, boolean eightWay, char glyph, com.badlogic.gdx.graphics.Color startColor, com.badlogic.gdx.graphics.Color endColor, float duration)
Convenience method to produce an explosion, splash, or burst effect.void
burst(int x, int y, boolean eightWay, char glyph, com.badlogic.gdx.graphics.Color startColor, com.badlogic.gdx.graphics.Color endColor, float rotationStrength, float duration)
Convenience method to produce an explosion, splash, or burst effect.void
burst(int x, int y, int distance, boolean eightWay, char glyph, com.badlogic.gdx.graphics.Color startColor, com.badlogic.gdx.graphics.Color endColor, boolean doubleWidth, float rotationStrength, float duration)
Convenience method to produce an explosion, splash, or burst effect.void
burst(int x, int y, int distance, boolean eightWay, char glyph, com.badlogic.gdx.graphics.Color startColor, com.badlogic.gdx.graphics.Color endColor, float rotationStrength, float duration)
Convenience method to produce an explosion, splash, or burst effect.int
cellHeight()
TextCellFactory.Glyph
cellToActor(int x, int y)
Created an Actor from the contents of the given x,y position on the grid.TextCellFactory.Glyph
cellToActor(int x, int y, boolean doubleWidth)
Created an Actor from the contents of the given x,y position on the grid; deleting the grid's String content at this cell.int
cellWidth()
protected float
clampDuration(float duration)
void
clear(int x, int y)
Removes the contents of this cell, leaving a transparent space.protected TextCellFactory.Glyph
createActor(int x, int y, char name, float encodedColor, boolean doubleWidth)
protected TextCellFactory.Glyph
createActor(int x, int y, char name, com.badlogic.gdx.graphics.Color color, boolean doubleWidth)
AnimatedEntity
directionMarker(int x, int y, boolean doubleWidth, com.badlogic.gdx.graphics.Color color)
AnimatedEntity
directionMarker(int x, int y, boolean doubleWidth, Collection<com.badlogic.gdx.graphics.Color> colors, float loopTime)
Create an AnimatedEntity at position x, y, using '^' as its contents, but as an image so it can be rotated.void
draw(com.badlogic.gdx.graphics.g2d.Batch batch, float parentAlpha)
Draws this SquidPanel and anyautoActors
it has, and callsActor.act(float)
for each AnimatedEntity this contains inanimatedEntities
orautoActors
.void
drawActor(com.badlogic.gdx.graphics.g2d.Batch batch, float parentAlpha, com.badlogic.gdx.scenes.scene2d.Actor ac)
Draws one AnimatedEntity, specifically the Actor it contains.void
drawActor(com.badlogic.gdx.graphics.g2d.Batch batch, float parentAlpha, AnimatedEntity ae)
Draws one AnimatedEntity, specifically the Actor it contains.void
erase()
Erases the entire panel, leaving only a transparent space.void
fade(int x, int y, com.badlogic.gdx.graphics.Color color, float duration)
Fade the cell at(x,y)
tocolor
.void
fixPosition(AnimatedEntity ae)
void
fixPositions()
OrderedSet<AnimatedEntity>
getAnimatedEntities()
AnimatedEntity
getAnimatedEntityByCell(int x, int y)
char
getAt(int x, int y)
com.badlogic.gdx.graphics.Color
getColorAt(int x, int y)
IColorCenter<com.badlogic.gdx.graphics.Color>
getColorCenter()
com.badlogic.gdx.graphics.Color
getDefaultForegroundColor()
int
getGridHeight()
The number of cells along the y-axis that will be rendered of this panelint
getGridOffsetX()
The X offset that the whole panel's internals will be rendered at.int
getGridOffsetY()
The Y offset that the whole panel's internals will be rendered at.int
getGridWidth()
The number of cells along the x-axis that will be rendered of this panel.com.badlogic.gdx.graphics.Color
getLightingColor()
boolean
getOnlyRenderEven()
Gets the status of a boolean flag used for rendering thin maps; it will almost always be false unless it was set to true withsetOnlyRenderEven(boolean)
.StringBuilder
getSnapshot()
Gets a "snapshot" of the data represented by this SquidPanel; stores the dimensions, the char data, and the color data in a way that can be set back to a SquidPanel usingsetFromSnapshot(String, int, int, int, int)
or its overload that takes a StringBuilder.StringBuilder
getSnapshot(int startX, int startY, int width, int height)
Gets a "snapshot" of the data represented by this SquidPanel; stores the dimensions, the char data, and the color data in a way that can be set back to a SquidPanel usingsetFromSnapshot(String, int, int, int, int)
or its overload that takes a StringBuilder.TextCellFactory
getTextCellFactory()
int
getTotalHeight()
Gets the total number of cells along the y-axis that this stores; this is usually equivalent togetGridHeight()
, but not if the constructorSquidPanel(int, int, TextCellFactory, IColorCenter, float, float, char[][])
was used to set a larger-than-normal map.int
getTotalWidth()
Gets the total number of cells along the x-axis that this stores; this is usually equivalent togetGridWidth()
, but not if the constructorSquidPanel(int, int, TextCellFactory, IColorCenter, float, float, char[][])
was used to set a larger-than-normal map.float
getxOffset()
float
getyOffset()
int
gridHeight()
int
gridWidth()
boolean
hasActiveAnimations()
void
put(char[][] chars)
Places the given characters into the grid starting at 0,0.void
put(char[][] chars, com.badlogic.gdx.graphics.Color[][] foregrounds)
void
put(int x, int y, char c)
Puts the characterc
at(x, y)
.void
put(int xOffset, int yOffset, char[][] chars)
void
put(int xOffset, int yOffset, char[][] chars, com.badlogic.gdx.graphics.Color foreground)
void
put(int xOffset, int yOffset, char[][] chars, com.badlogic.gdx.graphics.Color[][] foregrounds)
void
put(int xOffset, int yOffset, char[][] chars, com.badlogic.gdx.graphics.Color foreground, float colorMultiplier)
void
put(int x, int y, char c, float encodedColor)
Takes a unicode char for input.void
put(int x, int y, char c, float encodedColor, float colorMultiplier)
Takes a unicode char for input and a color multiplier that determines how much oflightingColor
will affect the given encodedColor.void
put(int x, int y, char c, float encodedColor, float colorMultiplier, float mixColor)
Intended for colored lighting; takes a unicode char for input and a color multiplier that determines how much of mixColor will affect encodedColor.void
put(int x, int y, char c, com.badlogic.gdx.graphics.Color color)
Takes a unicode char for input.void
put(int x, int y, char c, com.badlogic.gdx.graphics.Color color, float colorMultiplier)
Puts the given character at position x, y, with its color determined by the given color interpolated with this SquidPanel's lightingColor (default is white light) by the amount specified by colorMultiplier (0.0 causes no change to the given color, 1.0 uses the lightingColor only, and anything between 0 and 1 will produce some tint to color, and probably cache the produced color in the IColorCenter this uses).void
put(int x, int y, char c, com.badlogic.gdx.graphics.Color color, float mixAmount, com.badlogic.gdx.graphics.Color mix)
Puts the given character at position x, y, with its color determined by the given color interpolated with the given mix color by the amount specified by mixAmount (0.0 causes no change to the given color, 1.0 uses mix only, and anything between 0 and 1 will produce some tint to color, and probably cache the produced color in the IColorCenter this uses).void
put(int x, int y, float encodedColor)
Places a full cell of color at the given x,y position; this may be used as a background or foreground, depending on the implementation.void
put(int x, int y, float encodedColor, float colorMultiplier)
void
put(int x, int y, float encodedColor, float colorMultiplier, float mixColor)
void
put(int x, int y, int code)
Takes a unicode codepoint for input.void
put(int x, int y, int c, com.badlogic.gdx.graphics.Color color)
void
put(int x, int y, com.badlogic.gdx.graphics.Color color)
Putscolor
at(x, y)
(in the cell's entirety, i.e.void
put(int xOffset, int yOffset, com.badlogic.gdx.graphics.Color[][] foregrounds)
void
put(int x, int y, com.badlogic.gdx.graphics.Color color, float colorMultiplier)
void
put(int x, int y, com.badlogic.gdx.graphics.Color color, float mixAmount, com.badlogic.gdx.graphics.Color mix)
void
put(int xOffset, int yOffset, String string)
Puts the given string horizontally with the first character at the given offset.void
put(int xOffset, int yOffset, String string, boolean vertical)
Puts the given string horizontally or optionally vertically, with the first character at the given offset.void
put(int xOffset, int yOffset, String string, float encodedColor)
void
put(int xOffset, int yOffset, String string, float encodedColor, float colorMultiplier)
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 xOffset, int yOffset, String string, com.badlogic.gdx.graphics.Color foreground, boolean vertical)
Puts the given string horizontally or optionally vertically, with the first character at the given offset.void
put(int xOffset, int yOffset, String string, com.badlogic.gdx.graphics.Color foreground, float colorMultiplier)
void
put(int xOffset, int yOffset, String string, com.badlogic.gdx.graphics.Color foreground, Direction direction)
Puts the given string in the chosen direction, with the first character shown (not necessarily the first in the string) at the given offset.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
putBorders()
Changes the chars at the edge of the SquidPanel to be a border drawn with box drawing characters in white.void
putBorders(float encodedColor)
Changes the chars at the edge of the SquidPanel to be a border drawn with box drawing characters in the given color as a packed float.void
putBorders(float encodedColor, String caption)
Changes the chars at the edge of the SquidPanel to be a border drawn with box drawing characters in the given color as a packed float.void
putBorders(com.badlogic.gdx.graphics.Color color)
Changes the chars at the edge of the SquidPanel to be a border drawn with box drawing characters in the given Color, which will be run through any IColorCenter this has for filtering.void
putBorders(com.badlogic.gdx.graphics.Color color, String caption)
Changes the chars at the edge of the SquidPanel to be a border drawn with box drawing characters in the given Color, which will be run through any IColorCenter this has for filtering.void
putBordersCaptioned(float encodedColor, IColoredString<com.badlogic.gdx.graphics.Color> caption)
Changes the chars at the edge of the SquidPanel to be a border drawn with box drawing characters in the given color as a packed float.void
putBordersCaptioned(com.badlogic.gdx.graphics.Color color, IColoredString<com.badlogic.gdx.graphics.Color> caption)
Changes the chars at the edge of the SquidPanel to be a border drawn with box drawing characters in the given libGDX Color.void
recallActor(com.badlogic.gdx.scenes.scene2d.Actor a, boolean restoreSym)
void
recallActor(com.badlogic.gdx.scenes.scene2d.Actor a, boolean restoreSym, int nextX, int nextY)
void
recallActor(AnimatedEntity ae)
void
recallActor(AnimatedEntity ae, int nextX, int nextY)
void
recallActor(TextCellFactory.Glyph a, boolean restoreSym, int nextX, int nextY)
void
removeAnimatedEntity(AnimatedEntity ae)
void
setColorCenter(IColorCenter<com.badlogic.gdx.graphics.Color> scc)
Use this method if you use your ownIColorCenter
and want this panel not to allocate its own colors (or fillDefaultResources.getSCC()
but instead to the provided center.void
setDefaultForeground(com.badlogic.gdx.graphics.Color defaultForeground)
Sets the default foreground color.SquidPanel
setFromSnapshot(String snapshot)
Given a "snapshot" fromgetSnapshot(int, int, int, int)
, this assigns the chars and colors in this SquidPanel from 0,0 (inclusive) up to the dimensions stored in the snapshot to match the snapshot's data.SquidPanel
setFromSnapshot(StringBuilder snapshot)
Given a "snapshot" fromgetSnapshot(int, int, int, int)
, this assigns the chars and colors in this SquidPanel from 0,0 (inclusive) up to the dimensions stored in the snapshot to match the snapshot's data.SquidPanel
setFromSnapshot(StringBuilder snapshot, int putX, int putY)
Given a "snapshot" fromgetSnapshot(int, int, int, int)
, this assigns the chars and colors in this SquidPanel from the position given by putX,putY (inclusive) up to the dimensions stored in the snapshot (considering putX and putY as offsets) so they have the values stored in the snapshot.SquidPanel
setFromSnapshot(StringBuilder snapshot, int putX, int putY, int limitWidth, int limitHeight)
Given a "snapshot" fromgetSnapshot(int, int, int, int)
, this assigns the chars and colors in this SquidPanel from the position given by putX,putY (inclusive) to putX+limitWidth,putY+limitHeight (exclusive) so they have the values stored in the snapshot.SquidPanel
setFromSnapshot(String snapshot, int putX, int putY)
Given a "snapshot" fromgetSnapshot(int, int, int, int)
, this assigns the chars and colors in this SquidPanel from the position given by putX,putY (inclusive) up to the dimensions stored in the snapshot (considering putX and putY as offsets) so they have the values stored in the snapshot.SquidPanel
setFromSnapshot(String snapshot, int putX, int putY, int limitWidth, int limitHeight)
Given a "snapshot" fromgetSnapshot(int, int, int, int)
, this assigns the chars and colors in this SquidPanel from the position given by putX,putY (inclusive) to putX+limitWidth,putY+limitHeight (exclusive) so they have the values stored in the snapshot.void
setGridHeight(int gridHeight)
Sets the number of cells along the y-axis that will be rendered of this panel to gridHeight.void
setGridOffsetX(int gridOffsetX)
Sets the X offset that the whole panel's internals will be rendered at.void
setGridOffsetY(int gridOffsetY)
Sets the Y offset that the whole panel's internals will be rendered at.void
setGridWidth(int gridWidth)
Sets the number of cells along the x-axis that will be rendered of this panel to gridWidth.void
setLightingColor(com.badlogic.gdx.graphics.Color lightingColor)
void
setOffsets(float x, float y)
void
setOffsetX(float xOffset)
void
setOffsetY(float yOffset)
void
setOnlyRenderEven(boolean onlyRenderEven)
Sets the status of a boolean flag used for rendering thin maps; it should almost always be the default, which is false, unless you are using a thin-wall map, and then this should be true only if this SquidPanel is used for the background layer.void
setPosition(float x, float y)
Sets the position of the actor's bottom left corner.SquidPanel
setTextSize(float wide, float high)
Sets the size of the text in this SquidPanel (but not the size of the cells) to the given width and height in pixels (which may be stretched by viewports later on, if your program uses them).void
slide(int x, int y, int newX, int newY, float duration)
Start a movement animation for the object at the grid location x, y and moves it to newX, newY over a number of seconds given by duration (often 0.12f or somewhere around there).void
slide(int x, int y, String name, com.badlogic.gdx.graphics.Color color, int newX, int newY, float duration)
Slidesname
from(x,y)
to(newx, newy)
.void
slide(int x, int y, String name, com.badlogic.gdx.graphics.Color color, int newX, int newY, float duration, Runnable postRunnable)
Slidesname
from(x,y)
to(newx, newy)
.void
slide(AnimatedEntity ae, int newX, int newY, float duration)
Start a movement animation for the object at the grid location x, y and moves it to newX, newY over a number of seconds given by duration (often 0.12f or somewhere around there).void
slide(Coord start, Direction direction)
Starts a movement animation for the object at the given grid location at the default speed for one grid square in the direction provided.void
slide(Coord start, Coord end)
Starts a movement animation for the object at the given grid location at the default speed.void
slide(Coord start, Coord end, float duration)
Starts a sliding movement animation for the object at the given location at the provided speed.void
summon(float delay, int startX, int startY, int endX, int endY, char glyph, com.badlogic.gdx.graphics.Color startColor, com.badlogic.gdx.graphics.Color endColor, boolean doubleWidth, float startRotation, float endRotation, float duration)
Create a new Actor at (startX, startY) that looks like glyph but can rotate, and immediately starts changing color from startColor to endColor, changing position so it ends on the cell (endX, endY), and changing rotation from startRotation to endRotation, taking duration seconds to complete before removing the Actor.void
summon(int x, int y, char glyph, com.badlogic.gdx.graphics.Color startColor, com.badlogic.gdx.graphics.Color endColor, float startRotation, float endRotation, float duration)
Create a new Actor at (x, y) that looks like glyph but can rotate, and immediately starts changing color from startColor to endColor and changing rotation from startRotation to endRotation, taking duration seconds to complete before removing the Actor.void
summon(int startX, int startY, int endX, int endY, char glyph, com.badlogic.gdx.graphics.Color color, float startRotation, float endRotation, float duration)
Create a new Actor at (startX, startY) that looks like glyph but can rotate, sets its color, and immediately starts changing position so it ends on the cell (endX, endY) and changing rotation from startRotation to endRotation, taking duration seconds to complete before removing the Actor.void
summon(int startX, int startY, int endX, int endY, char glyph, com.badlogic.gdx.graphics.Color startColor, com.badlogic.gdx.graphics.Color endColor, boolean doubleWidth, float startRotation, float endRotation, float duration)
Create a new Actor at (startX, startY) that looks like glyph but can rotate, and immediately starts changing color from startColor to endColor, changing position so it ends on the cell (endX, endY), and changing rotation from startRotation to endRotation, taking duration seconds to complete before removing the Actor.void
summon(int startX, int startY, int endX, int endY, char glyph, com.badlogic.gdx.graphics.Color startColor, com.badlogic.gdx.graphics.Color endColor, float rotation, float duration)
Create a new Actor at (startX, startY) that looks like glyph but has the given rotation, and immediately starts changing color from startColor to endColor, and changing position so it ends on the cell (endX, endY), taking duration seconds to complete before removing the Actor.void
summon(int startX, int startY, int endX, int endY, char glyph, com.badlogic.gdx.graphics.Color startColor, com.badlogic.gdx.graphics.Color endColor, float startRotation, float endRotation, float duration)
Create a new Actor at (startX, startY) that looks like glyph but can rotate, and immediately starts changing color from startColor to endColor, changing position so it ends on the cell (endX, endY), and changing rotation from startRotation to endRotation, taking duration seconds to complete before removing the Actor.void
tint(float delay, int x, int y, com.badlogic.gdx.graphics.Color color, float duration)
Liketint(int, int, Color, float)
, but waits fordelay
(in seconds) before performing it.void
tint(float delay, int x, int y, com.badlogic.gdx.graphics.Color color, float duration, Runnable postRunnable)
Liketint(int, int, Color, float)
, but waits fordelay
(in seconds) before performing it.void
tint(int x, int y, com.badlogic.gdx.graphics.Color color, float duration)
Starts a tint animation for the object at(x,y)
for the givenduration
(in seconds).void
tint(AnimatedEntity ae, com.badlogic.gdx.graphics.Color color, float duration)
Starts a tint animation forae
for the givenduration
in seconds.void
wiggle(int x, int y, float duration)
Starts an wiggling animation for the object at the given location for the given duration in seconds.void
wiggle(AnimatedEntity ae, float duration)
Starts an wiggling animation for the object at the given location for the given duration in seconds.float
worldX(int gridX, boolean doubleWidth)
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.Group
act, addActor, addActorAfter, addActorAt, addActorBefore, applyTransform, applyTransform, childrenChanged, clear, clearChildren, computeTransform, debugAll, drawChildren, drawDebug, drawDebugChildren, findActor, getChild, getChildren, getCullingArea, hasChildren, hit, isTransform, localToDescendantCoordinates, removeActor, removeActor, removeActorAt, resetTransform, resetTransform, setCullingArea, setDebug, setStage, setTransform, swapActor, swapActor, toString
Methods inherited from class com.badlogic.gdx.scenes.scene2d.Actor
addAction, addCaptureListener, addListener, ancestorsVisible, ascendantsVisible, clearActions, clearListeners, clipBegin, clipBegin, clipEnd, debug, 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, 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, setRotation, setScale, setScale, setScaleX, setScaleY, setSize, setTouchable, setUserObject, setVisible, setWidth, setX, setX, setY, setY, setZIndex, sizeBy, sizeBy, sizeChanged, stageToLocalCoordinates, toBack, toFront
-
Field Details
-
DEFAULT_ANIMATION_DURATION
-
animationCount
-
defaultForeground
-
scc
-
cellWidth
-
cellHeight
-
gridWidth
-
gridHeight
-
gridOffsetX
-
gridOffsetY
-
contents
The 2D array of chars that this will render, using x,y indexing. Full-block cells that are completely filled with their color will be the char at Unicode codepoint 0, usually represented with'\0'
. -
colors
The 2D array of floats representing colors in a way that libGDX can efficiently use, ABGR-packed. Most use won't directly involve this field, but there are various techniques SquidLib uses to boost performance by treating a color as a float. This is mainly advantageous when many colors are involved and objects shouldn't be instantiated many times. You may want to consider usingSColor.lerpFloatColors(float, float, float)
if you expect to smoothly mix these float colors, which avoids creating intermediate Color objects. There are more methods like that in SColor. -
lightingColor
-
tmpColor
-
textFactory
-
xOffset
-
yOffset
-
lightingFloat
-
animatedEntities
-
autoActors
-
onlyRenderEven
For thin-wall maps, where only cells where x and y are both even numbers have backgrounds displayed. Should be false when using this SquidPanel for anything that isn't specifically a background of a map that uses the thin-wall method from ThinDungeonGenerator or something similar. Even the foregrounds of thin-wall maps should have this false, since ThinDungeonGenerator (in conjunction with DungeonUtility's hashesToLines method) makes thin lines for walls that should be displayed as between the boundaries of other cells. The overlap behavior needed for some "thin enough" cells to be displayed between the cells can be accomplished by usingsetTextSize(float, float)
to double the previously-given cell width and height.
-
-
Constructor Details
-
SquidPanel
Creates a bare-bones panel with all default values for text rendering.
This uses a default font that is not supplied in the JAR library of SquidLib; you need two files to use it if it does not render correctly:- https://github.com/SquidPony/SquidLib/blob/master/assets/Zodiac-Square-12x12.fnt
- https://github.com/SquidPony/SquidLib/blob/master/assets/Zodiac-Square-12x12.png
- Parameters:
gridWidth
- the number of cells horizontallygridHeight
- the number of cells vertically
-
SquidPanel
Creates a panel with the given grid and cell size. Uses a default square font.
This uses a default font that is not supplied in the JAR library of SquidLib; you need two files to use it if it does not render correctly:- https://github.com/SquidPony/SquidLib/blob/master/assets/Zodiac-Square-12x12.fnt
- https://github.com/SquidPony/SquidLib/blob/master/assets/Zodiac-Square-12x12.png
- Parameters:
gridWidth
- the number of cells horizontallygridHeight
- the number of cells verticallycellWidth
- the number of horizontal pixels in each cellcellHeight
- the number of vertical pixels in each cell
-
SquidPanel
Builds a panel with the given grid size and all other parameters determined by the factory. Even if sprite images are being used, a TextCellFactory is still needed to perform sizing and other utility functions. If the TextCellFactory has not yet been initialized, then it will be sized at 12x12 px per cell. If it is null then a default one will be created and initialized.- Parameters:
gridWidth
- the number of cells horizontallygridHeight
- the number of cells verticallyfactory
- the factory to use for cell rendering
-
SquidPanel
public SquidPanel(int gridWidth, int gridHeight, TextCellFactory factory, IColorCenter<com.badlogic.gdx.graphics.Color> center)Builds a panel with the given grid size and all other parameters determined by the factory. Even if sprite images are being used, a TextCellFactory is still needed to perform sizing and other utility functions. If the TextCellFactory has not yet been initialized, then it will be sized at 12x12 px per cell. If it is null then a default one will be created and initialized.- Parameters:
gridWidth
- the number of cells horizontallygridHeight
- the number of cells verticallyfactory
- the factory to use for cell renderingcenter
- the color center to use. Can benull
, which will use a default
-
SquidPanel
public SquidPanel(int gridWidth, int gridHeight, TextCellFactory factory, IColorCenter<com.badlogic.gdx.graphics.Color> center, float xOffset, float yOffset)Builds a panel with the given grid size and all other parameters determined by the factory. Even if sprite images are being used, a TextCellFactory is still needed to perform sizing and other utility functions.
If the TextCellFactory has not yet been initialized, then it will be sized at 12x12 px per cell. If it is null then a default one will be created and initialized. The xOffset and yOffset arguments are measured in pixels or whatever sub-cell unit of measure your game uses (world coordinates, in libGDX parlance), and change where the SquidPanel starts drawing by simply adding to the initial x and y coordinates. 0 and 0 are usually fine.- Parameters:
gridWidth
- the number of cells horizontallygridHeight
- the number of cells verticallyfactory
- the factory to use for cell renderingcenter
- the color center to use. Can benull
, which will use a defaultxOffset
- the x offset to start rendering at, in pixels (or some other sub-cell measurement your game uses)yOffset
- the y offset to start rendering at, in pixels (or some other sub-cell measurement your game uses)
-
SquidPanel
public SquidPanel(int gridWidth, int gridHeight, TextCellFactory factory, IColorCenter<com.badlogic.gdx.graphics.Color> center, float xOffset, float yOffset, char[][] actualMap)Builds a panel with the given grid size and all other parameters determined by the factory. Even if sprite images are being used, a TextCellFactory is still needed to perform sizing and other utility functions. Importantly, this constructor takes a 2D char array argument that can be sized differently than the displayed area. The displayed area is gridWidth by gridHeight in cells, but the actualMap argument can be much larger, and only a portion will be displayed at a time. This requires some special work with the Camera and Viewports to get working correctly; in the squidlib module's examples, EverythingDemo may be a good place to see how this can be done. You can pass null for actualMap, which will simply create a char array to use internally that is exactly gridWidth by gridHeight, in cells.
If the TextCellFactory has not yet been initialized, then it will be sized at 12x12 px per cell. If it is null then a default one will be created and initialized. The xOffset and yOffset arguments are measured in pixels or whatever sub-cell unit of measure your game uses (world coordinates, in libGDX parlance), and change where the SquidPanel starts drawing by simply adding to the initial x and y coordinates. 0 and 0 are usually fine.- Parameters:
gridWidth
- the number of cells horizontallygridHeight
- the number of cells verticallyfactory
- the factory to use for cell renderingcenter
- the color center to use. Can benull
, which will use a defaultxOffset
- the x offset to start rendering at, in pixels (or some other sub-cell measurement your game uses)yOffset
- the y offset to start rendering at, in pixels (or some other sub-cell measurement your game uses)actualMap
- will often be a different size than gridWidth by gridHeight, which enables camera scrolling
-
-
Method Details
-
put
Places the given characters into the grid starting at 0,0.- Parameters:
chars
-
-
put
- Specified by:
put
in interfaceIPackedColorPanel
- Parameters:
chars
- Can benull
, indicating that only colors must be put.
-
put
-
put
public void put(int xOffset, int yOffset, char[][] chars, com.badlogic.gdx.graphics.Color[][] foregrounds) -
put
-
put
public void put(int xOffset, int yOffset, char[][] chars, com.badlogic.gdx.graphics.Color foreground) -
put
Puts the given string horizontally with the first character at the given offset. 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. Will use the default color for this component to draw the characters.- Parameters:
xOffset
- the x coordinate of the first characteryOffset
- the y coordinate of the first characterstring
- the characters to be displayed
-
put
public void put(int xOffset, int yOffset, IColoredString<? extends com.badlogic.gdx.graphics.Color> cs)Description copied from interface:IPackedColorPanel
Puts the given string horizontally with the first character at the given offset, using the colors thatcs
provides. 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
- The string to display, with its colors.
-
put
public void put(int xOffset, int yOffset, String string, com.badlogic.gdx.graphics.Color foreground)Description copied from interface:IPackedColorPanel
Puts the given string horizontally with the first character at the given offset. 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 draw the characters
-
put
-
put
-
put
-
put
public void put(int xOffset, int yOffset, char[][] chars, com.badlogic.gdx.graphics.Color foreground, float colorMultiplier) -
put
Puts the given string horizontally or optionally vertically, with the first character at the given offset. 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. Will use the default color for this component to draw the characters.- Parameters:
xOffset
- the x coordinate of the first characteryOffset
- the y coordinate of the first characterstring
- the characters to be displayedvertical
- true if the text should be written vertically, from top to bottom
-
put
public void put(int xOffset, int yOffset, String string, com.badlogic.gdx.graphics.Color foreground, boolean vertical)Puts the given string horizontally or optionally vertically, with the first character at the given offset. 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.- Parameters:
xOffset
- the x coordinate of the first characteryOffset
- the y coordinate of the first characterstring
- the characters to be displayedforeground
- the color to draw the charactersvertical
- true if the text should be written vertically, from top to bottom
-
put
public void put(int xOffset, int yOffset, String string, com.badlogic.gdx.graphics.Color foreground, Direction direction)Puts the given string in the chosen direction, with the first character shown (not necessarily the first in the string) at the given offset. If you useDirection.LEFT
, then this effectively reverses the String and prints it with the last character of the String at the minimum-x position, which is the same position that the first character would be if you printed normally or if you gave this RIGHT (x is xOffset, y is yOffset). Giving UP acts similarly to LEFT, but has the last character at the minimum-y position and has the first character below it. The diagonals act as you would expect, combining the behavior of one of UP or DOWN with one of LEFT or RIGHT.
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.- Parameters:
xOffset
- the x coordinate of the first characteryOffset
- the y coordinate of the first characterstring
- the characters to be displayedforeground
- the color to draw the charactersdirection
- the direction the text should be written in, such asDirection.RIGHT
for normal layout
-
putBorders
Changes the chars at the edge of the SquidPanel to be a border drawn with box drawing characters in white. -
putBorders
Changes the chars at the edge of the SquidPanel to be a border drawn with box drawing characters in the given Color, which will be run through any IColorCenter this has for filtering. If caption is non-null, then this puts that String starting at x=1, y=0.- Parameters:
color
- a libGDX Color to use for the borderscaption
- an optional caption that will be drawn at (1, 0). May be null.- See Also:
Another method that takes an IColoredString caption
-
putBorders
Changes the chars at the edge of the SquidPanel to be a border drawn with box drawing characters in the given Color, which will be run through any IColorCenter this has for filtering.- Parameters:
color
- a libGDX Color to use for the borders
-
putBorders
Changes the chars at the edge of the SquidPanel to be a border drawn with box drawing characters in the given color as a packed float.- Parameters:
encodedColor
- a packed float color to use for the borders, as fromColor.toFloatBits()
-
putBorders
Changes the chars at the edge of the SquidPanel to be a border drawn with box drawing characters in the given color as a packed float. If caption is non-null, then this puts that String starting at x=1, y=0.- Parameters:
encodedColor
- a packed float color to use for the borders, as fromColor.toFloatBits()
caption
- an optional caption that will be drawn at (1, 0). May be null to have no caption.- See Also:
Another method that takes an IColoredString caption
-
putBordersCaptioned
public void putBordersCaptioned(com.badlogic.gdx.graphics.Color color, IColoredString<com.badlogic.gdx.graphics.Color> caption)Changes the chars at the edge of the SquidPanel to be a border drawn with box drawing characters in the given libGDX Color. If caption is non-null, then this puts that IColoredString starting at x=1, y=0.- Parameters:
color
- a libGDX Color to use for the borderscaption
- an optional caption as an IColoredString that will be drawn at (1, 0). May be null to have no caption. Will be colored independently from the border lines.
-
putBordersCaptioned
public void putBordersCaptioned(float encodedColor, IColoredString<com.badlogic.gdx.graphics.Color> caption)Changes the chars at the edge of the SquidPanel to be a border drawn with box drawing characters in the given color as a packed float. If caption is non-null, then this puts that IColoredString starting at x=1, y=0.- Parameters:
encodedColor
- a packed float color to use for the borders, as fromColor.toFloatBits()
caption
- an optional caption as an IColoredString that will be drawn at (1, 0). May be null to have no caption. Will be colored independently from the border lines.
-
erase
Erases the entire panel, leaving only a transparent space. -
clear
Description copied from interface:IPackedColorPanel
Removes the contents of this cell, leaving a transparent space.- Specified by:
clear
in interfaceIPackedColorPanel
-
put
Description copied from interface:IPackedColorPanel
Putscolor
at(x, y)
(in the cell's entirety, i.e. in the background).- Specified by:
put
in interfaceIPackedColorPanel
-
put
Description copied from interface:IPackedColorPanel
Places a full cell of color at the given x,y position; this may be used as a background or foreground, depending on the implementation. The color is given as a packed float, the kind produced byColor.toFloatBits()
. If the implementation performs color filtering on Color objects, it generally won't on packed float colors.- Specified by:
put
in interfaceIPackedColorPanel
- Parameters:
x
- x position of the celly
- y position of the cellencodedColor
- color for the full cell as a packed float, as made byColor.toFloatBits()
-
put
-
put
-
blend
Description copied from interface:IPackedColorPanel
Using the existing 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)
-
put
-
put
public void put(int x, int y, com.badlogic.gdx.graphics.Color color, float mixAmount, com.badlogic.gdx.graphics.Color mix) -
put
Description copied from interface:IPackedColorPanel
Puts the characterc
at(x, y)
.- Specified by:
put
in interfaceIPackedColorPanel
-
put
Takes a unicode codepoint for input.- Parameters:
x
-y
-code
-
-
put
-
put
Takes a unicode char for input.- Specified by:
put
in interfaceIPackedColorPanel
- Parameters:
x
-y
-c
-color
-
-
put
Takes a unicode char for input.- Specified by:
put
in interfaceIPackedColorPanel
- Parameters:
x
-y
-c
-encodedColor
- a float color as produced bySColor.floatGet(float, float, float, float)
-
put
Takes a unicode char for input and a color multiplier that determines how much oflightingColor
will affect the given encodedColor. The encodedColor is a float that might be produced byColor.toFloatBits()
or by mixing multiple such floats withSColor.lerpFloatColors(float, float, float)
.- Parameters:
x
-y
-c
-encodedColor
- a float color as produced bySColor.floatGet(float, float, float, float)
colorMultiplier
- how much oflightingColor
to use in place of encodedColor, from 0.0 to 1.0
-
put
Intended for colored lighting; takes a unicode char for input and a color multiplier that determines how much of mixColor will affect encodedColor. Both encodedColor and mixColor are floats that might be produced byColor.toFloatBits()
or by mixing multiple such floats withSColor.lerpFloatColors(float, float, float)
; colorMultiplier is a normal float between 0.0f and 1.0f .- Parameters:
x
-y
-c
-encodedColor
- a float color as produced bySColor.floatGet(float, float, float, float)
colorMultiplier
- how much of mixColor to use in place of encodedColor, from 0.0 to 1.0mixColor
- a color to mix with encodedColor, typically as part of colored lighting
-
put
public void put(int x, int y, char c, com.badlogic.gdx.graphics.Color color, float colorMultiplier)Puts the given character at position x, y, with its color determined by the given color interpolated with this SquidPanel's lightingColor (default is white light) by the amount specified by colorMultiplier (0.0 causes no change to the given color, 1.0 uses the lightingColor only, and anything between 0 and 1 will produce some tint to color, and probably cache the produced color in the IColorCenter this uses). -
put
public void put(int x, int y, char c, com.badlogic.gdx.graphics.Color color, float mixAmount, com.badlogic.gdx.graphics.Color mix)Puts the given character at position x, y, with its color determined by the given color interpolated with the given mix color by the amount specified by mixAmount (0.0 causes no change to the given color, 1.0 uses mix only, and anything between 0 and 1 will produce some tint to color, and probably cache the produced color in the IColorCenter this uses).
Note, unlikeput(int, int, char, float, float, float)
, this will use the IColorCenter to produce the finished color, which may be slightly slower if you don't need any of IColorCenter's features, and will use more memory if many colors are cached, but has the advantage of being able to adjust colors with filters. -
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.
-
gridHeight
- Specified by:
gridHeight
in interfaceIPackedColorPanel
- Returns:
- The number of cells that this panel spans, vertically.
-
gridWidth
- Specified by:
gridWidth
in interfaceIPackedColorPanel
- Returns:
- The number of cells that this panel spans, horizontally.
-
getTextCellFactory
- Returns:
- The
TextCellFactory
backingthis
.
-
setTextSize
Sets the size of the text in this SquidPanel (but not the size of the cells) to the given width and height in pixels (which may be stretched by viewports later on, if your program uses them).- Parameters:
wide
- the width of a glyph in pixelshigh
- the height of a glyph in pixels- Returns:
- this for chaining
-
draw
Draws this SquidPanel and anyautoActors
it has, and callsActor.act(float)
for each AnimatedEntity this contains inanimatedEntities
orautoActors
.
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.Group
- Parameters:
batch
- a Batch such as aFilterBatch
that must be between a begin() and end() call; usually done by StageparentAlpha
- only used when drawing children of this SquidPanel
-
drawActor
public void drawActor(com.badlogic.gdx.graphics.g2d.Batch batch, float parentAlpha, AnimatedEntity ae)Draws one AnimatedEntity, specifically the Actor it contains. Batch must be between start() and end()- Parameters:
batch
- Must have start() called already but not stop() yet during this frame.parentAlpha
- This can be assumed to be 1.0f if you don't know itae
- The AnimatedEntity to draw; the position to draw ae is stored inside it.
-
drawActor
public void drawActor(com.badlogic.gdx.graphics.g2d.Batch batch, float parentAlpha, com.badlogic.gdx.scenes.scene2d.Actor ac)Draws one AnimatedEntity, specifically the Actor it contains. Batch must be between start() and end()- Parameters:
batch
- Must have start() called already but not stop() yet during this frame.parentAlpha
- This can be assumed to be 1.0f if you don't know itac
- The Actor to draw; the position to draw ac is modified and reset based on some fields of this object
-
setDefaultForeground
Description copied from interface:IPackedColorPanel
Sets the default foreground color.- Specified by:
setDefaultForeground
in interfaceIPackedColorPanel
-
getDefaultForegroundColor
- Specified by:
getDefaultForegroundColor
in interfaceIPackedColorPanel
- Returns:
- The default foreground color (if none was set with
IPackedColorPanel.setDefaultForeground(Color)
), or the last color set withIPackedColorPanel.setDefaultForeground(Color)
. Cannot benull
.
-
getAnimatedEntityByCell
-
animateActor
Create an AnimatedEntity at position x, y, using the char c in the given color.- Parameters:
x
-y
-c
-color
-- Returns:
-
animateActor
public AnimatedEntity animateActor(int x, int y, boolean doubleWidth, char c, com.badlogic.gdx.graphics.Color color)Create an AnimatedEntity at position x, y, using the char c in the given color. If doubleWidth is true, treats the char c as the left char to be placed in a grid of 2-char cells.- Parameters:
x
-y
-doubleWidth
-c
-color
-- Returns:
-
animateActor
Create an AnimatedEntity at position x, y, using the String s in the given color.- Parameters:
x
-y
-s
-color
-- Returns:
-
animateActor
public AnimatedEntity animateActor(int x, int y, boolean doubleWidth, String s, com.badlogic.gdx.graphics.Color color)Create an AnimatedEntity at position x, y, using the String s in the given color. If doubleWidth is true, treats the String s as starting in the left cell of a pair to be placed in a grid of 2-char cells.- Parameters:
x
-y
-doubleWidth
-s
-color
-- Returns:
-
animateActor
public AnimatedEntity animateActor(int x, int y, boolean doubleWidth, String s, Collection<com.badlogic.gdx.graphics.Color> colors)Create an AnimatedEntity at position x, y, using the String s in the given color. If doubleWidth is true, treats the String s as starting in the left cell of a pair to be placed in a grid of 2-char cells.- Parameters:
x
-y
-doubleWidth
-s
-colors
-- Returns:
-
animateActor
public AnimatedEntity animateActor(int x, int y, boolean doubleWidth, String s, Collection<com.badlogic.gdx.graphics.Color> colors, float loopTime)Create an AnimatedEntity at position x, y, using the String s in the given color. If doubleWidth is true, treats the String s as starting in the left cell of a pair to be placed in a grid of 2-char cells.- Parameters:
x
-y
-doubleWidth
-s
-colors
-loopTime
-- Returns:
-
directionMarker
public AnimatedEntity directionMarker(int x, int y, boolean doubleWidth, Collection<com.badlogic.gdx.graphics.Color> colors, float loopTime)Create an AnimatedEntity at position x, y, using '^' as its contents, but as an image so it can be rotated. Uses the given colors in a looping pattern, that doesn't count as an animation. If doubleWidth is true, treats the '^' as starting in the middle of a 2-char cell.- Parameters:
x
-y
-doubleWidth
-colors
-loopTime
-- Returns:
-
directionMarker
public AnimatedEntity directionMarker(int x, int y, boolean doubleWidth, com.badlogic.gdx.graphics.Color color) -
animateActor
public AnimatedEntity animateActor(int x, int y, com.badlogic.gdx.graphics.g2d.TextureRegion texture)Create an AnimatedEntity at position x, y, using a TextureRegion with no color modifications, which will be stretched to fit one cell.- Parameters:
x
-y
-texture
-- Returns:
-
animateActor
public AnimatedEntity animateActor(int x, int y, com.badlogic.gdx.graphics.g2d.TextureRegion texture, com.badlogic.gdx.graphics.Color color)Create an AnimatedEntity at position x, y, using a TextureRegion with the given color, which will be stretched to fit one cell.- Parameters:
x
-y
-texture
-color
-- Returns:
-
animateActor
public AnimatedEntity animateActor(int x, int y, boolean doubleWidth, com.badlogic.gdx.graphics.g2d.TextureRegion texture)Create an AnimatedEntity at position x, y, using a TextureRegion with no color modifications, which will be stretched to fit one cell, or two cells if doubleWidth is true.- Parameters:
x
-y
-doubleWidth
-texture
-- Returns:
-
animateActor
public AnimatedEntity animateActor(int x, int y, boolean doubleWidth, com.badlogic.gdx.graphics.g2d.TextureRegion texture, com.badlogic.gdx.graphics.Color color)Create an AnimatedEntity at position x, y, using a TextureRegion with the given color, which will be stretched to fit one cell, or two cells if doubleWidth is true.- Parameters:
x
-y
-doubleWidth
-texture
-color
-- Returns:
-
animateActor
public AnimatedEntity animateActor(int x, int y, boolean doubleWidth, com.badlogic.gdx.graphics.g2d.TextureRegion texture, Collection<com.badlogic.gdx.graphics.Color> colors)Create an AnimatedEntity at position x, y, using a TextureRegion with the given color, which will be stretched to fit one cell, or two cells if doubleWidth is true.- Parameters:
x
-y
-doubleWidth
-texture
-colors
-- Returns:
-
animateActor
public AnimatedEntity animateActor(int x, int y, boolean doubleWidth, com.badlogic.gdx.graphics.g2d.TextureRegion texture, Collection<com.badlogic.gdx.graphics.Color> colors, float loopTime)Create an AnimatedEntity at position x, y, using a TextureRegion with the given color, which will be stretched to fit one cell, or two cells if doubleWidth is true.- Parameters:
x
-y
-doubleWidth
-texture
-colors
-- Returns:
-
animateActor
public AnimatedEntity animateActor(int x, int y, boolean doubleWidth, boolean stretch, com.badlogic.gdx.graphics.g2d.TextureRegion texture)Create an AnimatedEntity at position x, y, using a TextureRegion with no color modifications, which, if and only if stretch is true, will be stretched to fit one cell, or two cells if doubleWidth is true. If stretch is false, this will preserve the existing size of texture.- Parameters:
x
-y
-doubleWidth
-stretch
-texture
-- Returns:
-
animateActor
public AnimatedEntity animateActor(int x, int y, boolean doubleWidth, boolean stretch, com.badlogic.gdx.graphics.g2d.TextureRegion texture, com.badlogic.gdx.graphics.Color color)Create an AnimatedEntity at position x, y, using a TextureRegion with the given color, which, if and only if stretch is true, will be stretched to fit one cell, or two cells if doubleWidth is true. If stretch is false, this will preserve the existing size of texture.- Parameters:
x
-y
-doubleWidth
-stretch
-texture
-color
-- Returns:
-
cellToActor
Created an Actor from the contents of the given x,y position on the grid.- Parameters:
x
-y
-- Returns:
-
cellToActor
Created an Actor from the contents of the given x,y position on the grid; deleting the grid's String content at this cell.- Parameters:
x
-y
-doubleWidth
-- Returns:
- A fresh
Actor
, that has just been added tothis
.
-
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
-
createActor
protected TextCellFactory.Glyph createActor(int x, int y, char name, com.badlogic.gdx.graphics.Color color, boolean doubleWidth) -
createActor
protected TextCellFactory.Glyph createActor(int x, int y, char name, float encodedColor, boolean doubleWidth) -
adjustX
-
adjustY
-
recallActor
-
recallActor
public void recallActor(com.badlogic.gdx.scenes.scene2d.Actor a, boolean restoreSym, int nextX, int nextY) -
recallActor
-
recallActor
-
recallActor
-
fixPosition
-
fixPositions
-
bump
Start a bumping animation in the given direction that will last duration seconds.- Parameters:
ae
- an AnimatedEntity returned by animateActor()direction
-duration
- a float, measured in seconds, for how long the animation should last; commonly 0.12f
-
bump
Start a bumping animation in the given direction that will last duration seconds.- Parameters:
x
-y
-direction
-duration
- a float, measured in seconds, for how long the animation should last; commonly 0.12f
-
bump
Starts a bumping animation in the direction provided.- Parameters:
x
-y
-direction
-
-
bump
Starts a bumping animation in the direction provided.- Parameters:
location
-direction
-
-
slide
Start a movement animation for the object at the grid location x, y and moves it to newX, newY over a number of seconds given by duration (often 0.12f or somewhere around there).- Parameters:
ae
- an AnimatedEntity returned by animateActor()newX
-newY
-duration
-
-
slide
Start a movement animation for the object at the grid location x, y and moves it to newX, newY over a number of seconds given by duration (often 0.12f or somewhere around there).- Parameters:
x
-y
-newX
-newY
-duration
-
-
slide
public void slide(int x, int y, String name, com.badlogic.gdx.graphics.Color color, int newX, int newY, float duration)Slidesname
from(x,y)
to(newx, newy)
. Ifname
orcolor
isnull
, it is picked from this panel (hereby removing the current name, if any).- Parameters:
x
- Where to start the slide, horizontally.y
- Where to start the slide, vertically.name
- The name to slide, ornull
to pick it from this panel's(x,y)
cell.color
- The color to use, ornull
to pick it from this panel's(x,y)
cell.newX
- Where to end the slide, horizontally.newY
- Where to end the slide, vertically.duration
- The animation's duration.
-
slide
public void slide(int x, int y, String name, com.badlogic.gdx.graphics.Color color, int newX, int newY, float duration, Runnable postRunnable)Slidesname
from(x,y)
to(newx, newy)
. Ifname
orcolor
isnull
, it is picked from this panel (thereby removing the current name, if any). This also allows a Runnable to be given aspostRunnable
to be run after the slide completes.- Parameters:
x
- Where to start the slide, horizontally.y
- Where to start the slide, vertically.name
- The name to slide, ornull
to pick it from this panel's(x,y)
cell.color
- The color to use, ornull
to pick it from this panel's(x,y)
cell.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
Starts a movement animation for the object at the given grid location at the default speed.- Parameters:
start
- Coord to pick up a tile from and slideend
- Coord to end the slide on
-
slide
Starts a movement animation for the object at the given grid location at the default speed for one grid square in the direction provided.- Parameters:
start
- Coord to pick up a tile from and slidedirection
- Direction enum that indicates which way the slide should go
-
slide
Starts a sliding movement animation for the object at the given location at the provided speed. The duration is how many seconds should pass for the entire animation.- Parameters:
start
- Coord to pick up a tile from and slideend
- Coord to end the slide onduration
- in seconds, as a float
-
wiggle
Starts an wiggling animation for the object at the given location for the given duration in seconds.- Parameters:
ae
- an AnimatedEntity returned by animateActor()duration
- in seconds, as a float
-
wiggle
Starts an wiggling animation for the object at the given location for the given duration in seconds.- Parameters:
x
-y
-duration
-
-
tint
Starts a tint animation forae
for the givenduration
in seconds.- Parameters:
ae
- an AnimatedEntity returned by animateActor()color
- what to transition ae's color towards, and then transition back fromduration
- how long the total "round-trip" transition should take in seconds
-
tint
Liketint(int, int, Color, float)
, but waits fordelay
(in seconds) before performing it.- 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 tintcolor
- what to transition ae's color towards, and then transition back fromduration
- how long the total "round-trip" transition should take in seconds
-
tint
public void tint(float delay, int x, int y, com.badlogic.gdx.graphics.Color color, float duration, Runnable postRunnable)Liketint(int, int, Color, float)
, but waits fordelay
(in seconds) before performing it. Additionally, enqueuepostRunnable
for running after the created action ends.- 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 tintcolor
- what to transition ae's color towards, and then transition back fromduration
- 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
Starts a tint animation for the object at(x,y)
for the givenduration
(in seconds).- Parameters:
x
- the x-coordinate of the cell to tinty
- the y-coordinate of the cell to tintcolor
-duration
-
-
fade
Fade the cell at(x,y)
tocolor
. Contrary totint(int, int, Color, float)
, this action does not restore the cell's color at the end of its execution. This is for example useful to fade the game screen when the rogue dies.- Parameters:
x
- the x-coordinate of the cell to tinty
- the y-coordinate of the cell to tintcolor
- The color at the end of the fadeout.duration
- The fadeout's duration.
-
summon
public void summon(int x, int y, char glyph, com.badlogic.gdx.graphics.Color startColor, com.badlogic.gdx.graphics.Color endColor, float startRotation, float endRotation, float duration)Create a new Actor at (x, y) that looks like glyph but can rotate, and immediately starts changing color from startColor to endColor and changing rotation from startRotation to endRotation, taking duration seconds to complete before removing the Actor.- Parameters:
x
- the x position in cells; doesn't changey
- the y position in cells; doesn't changeglyph
- the char to show (the same char throughout the effect, but it can rotate)startColor
- the starting ColorendColor
- the Color to transition tostartRotation
- the amount of rotation, in degrees, the glyph should start atendRotation
- the amount of rotation, in degrees, the glyph should end atduration
- the duration in seconds for the effect
-
summon
public void summon(int startX, int startY, int endX, int endY, char glyph, com.badlogic.gdx.graphics.Color color, float startRotation, float endRotation, float duration)Create a new Actor at (startX, startY) that looks like glyph but can rotate, sets its color, and immediately starts changing position so it ends on the cell (endX, endY) and changing rotation from startRotation to endRotation, taking duration seconds to complete before removing the Actor.- 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 cellsglyph
- the char to show (the same char throughout the effect, but it can rotate)color
- the Color of the glyph throughout the effectstartRotation
- the amount of rotation, in degrees, the glyph should start atendRotation
- the amount of rotation, in degrees, the glyph should end atduration
- the duration in seconds for the effect
-
summon
public void summon(int startX, int startY, int endX, int endY, char glyph, com.badlogic.gdx.graphics.Color startColor, com.badlogic.gdx.graphics.Color endColor, float rotation, float duration)Create a new Actor at (startX, startY) that looks like glyph but has the given rotation, and immediately starts changing color from startColor to endColor, and changing position so it ends on the cell (endX, endY), taking duration seconds to complete before removing the Actor.- 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 cellsglyph
- the char to show (the same char throughout the effect, but it can rotate)startColor
- the starting ColorendColor
- the Color to transition torotation
- the amount of rotation, in degrees, the glyph should have throughout the effectduration
- the duration in seconds for the effect
-
summon
public void summon(int startX, int startY, int endX, int endY, char glyph, com.badlogic.gdx.graphics.Color startColor, com.badlogic.gdx.graphics.Color endColor, float startRotation, float endRotation, float duration)Create a new Actor at (startX, startY) that looks like glyph but can rotate, and immediately starts changing color from startColor to endColor, changing position so it ends on the cell (endX, endY), and changing rotation from startRotation to endRotation, taking duration seconds to complete before removing the Actor.- 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 cellsglyph
- the char to show (the same char throughout the effect, but it can rotate)startColor
- the starting ColorendColor
- the Color to transition tostartRotation
- the amount of rotation, in degrees, the glyph should start atendRotation
- the amount of rotation, in degrees, the glyph should end atduration
- the duration in seconds for the effect
-
summon
public void summon(int startX, int startY, int endX, int endY, char glyph, com.badlogic.gdx.graphics.Color startColor, com.badlogic.gdx.graphics.Color endColor, boolean doubleWidth, float startRotation, float endRotation, float duration)Create a new Actor at (startX, startY) that looks like glyph but can rotate, and immediately starts changing color from startColor to endColor, changing position so it ends on the cell (endX, endY), and changing rotation from startRotation to endRotation, taking duration seconds to complete before removing the Actor. Allows setting doubleWidth, which centers the created Actor in the space between the two glyphs in a cell.- 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 cellsglyph
- the char to show (the same char throughout the effect, but it can rotate)startColor
- the starting ColorendColor
- the Color to transition todoubleWidth
- true if this uses double-width cells, false in most casesstartRotation
- the amount of rotation, in degrees, the glyph should start atendRotation
- the amount of rotation, in degrees, the glyph should end atduration
- the duration in seconds for the effect
-
summon
public void summon(float delay, int startX, int startY, int endX, int endY, char glyph, com.badlogic.gdx.graphics.Color startColor, com.badlogic.gdx.graphics.Color endColor, boolean doubleWidth, float startRotation, float endRotation, float duration)Create a new Actor at (startX, startY) that looks like glyph but can rotate, and immediately starts changing color from startColor to endColor, changing position so it ends on the cell (endX, endY), and changing rotation from startRotation to endRotation, taking duration seconds to complete before removing the Actor. Allows setting doubleWidth, which centers the created Actor in the space between the two glyphs in a cell.- Parameters:
delay
- amount of time, in seconds, to wait 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 cellsglyph
- the char to show (the same char throughout the effect, but it can rotate)startColor
- the starting ColorendColor
- the Color to transition todoubleWidth
- true if this uses double-width cells, false in most casesstartRotation
- the amount of rotation, in degrees, the glyph should start atendRotation
- the amount of rotation, in degrees, the glyph should end atduration
- the duration in seconds for the effect
-
burst
public void burst(int x, int y, boolean eightWay, char glyph, com.badlogic.gdx.graphics.Color startColor, float duration)Convenience method to produce an explosion, splash, or burst effect. Callssummon(float, int, int, int, int, char, Color, Color, boolean, float, float, float)
repeatedly with different parameters. As with summon(), this creates temporary Actors that change color, position, and rotation. This overload always moves Actors 1 cell away, which is a safe default, uses a "normal" amount of rotation for for all of the actors (a value of 1f if you used another overload), and always uses an end color that is a modified copy of startColor with 0 alpha (making the Actors all fade to transparent). The parameter eightWay determines whether this produces 4 (cardinal) or 8 (cardinal and diagonal) rotations and directions.- Parameters:
x
- the starting, center, x-position to create all Actors aty
- the starting, center, y-position to create all Actors ateightWay
- if true, creates 8 Actors and moves them away in a square, otherwise, 4 Actors in a diamondglyph
- the char to make a rotate-able Actor of; should definitely be visiblestartColor
- the color to start the effect withduration
- how long, in seconds, the effect should last
-
burst
public void burst(int x, int y, boolean eightWay, char glyph, com.badlogic.gdx.graphics.Color startColor, com.badlogic.gdx.graphics.Color endColor, float duration)Convenience method to produce an explosion, splash, or burst effect. Callssummon(float, int, int, int, int, char, Color, Color, boolean, float, float, float)
repeatedly with different parameters. As with summon(), this creates temporary Actors that change color, position, and rotation. This overload always moves Actors 1 cell away, which is a safe default, and uses a "normal" amount of rotation for all of the actors (a value of 1f if you used another overload). The parameter eightWay determines whether this produces 4 (cardinal) or 8 (cardinal and diagonal) rotations and directions.- Parameters:
x
- the starting, center, x-position to create all Actors aty
- the starting, center, y-position to create all Actors ateightWay
- if true, creates 8 Actors and moves them away in a square, otherwise, 4 Actors in a diamondglyph
- the char to make a rotate-able Actor of; should definitely be visiblestartColor
- the color to start the effect withendColor
- the color to end the effect onduration
- how long, in seconds, the effect should last
-
burst
public void burst(int x, int y, boolean eightWay, char glyph, com.badlogic.gdx.graphics.Color startColor, com.badlogic.gdx.graphics.Color endColor, float rotationStrength, float duration)Convenience method to produce an explosion, splash, or burst effect. Callssummon(float, int, int, int, int, char, Color, Color, boolean, float, float, float)
repeatedly with different parameters. As with summon(), this creates temporary Actors that change color, position, and rotation. This overload always moves Actors 1 cell away, which is a safe default. Some parameters need explanation: eightWay determines whether this produces 4 (cardinal) or 8 (cardinal and diagonal) rotations and directions; rotationStrength can default to 1 if you want some rotation (which looks good) or 0 if you want the Actors to start at the correct rotation and not change that rotation over the course of the effect, but can be between 0 and 1 or higher than 1 (negative values may also work).- Parameters:
x
- the starting, center, x-position to create all Actors aty
- the starting, center, y-position to create all Actors ateightWay
- if true, creates 8 Actors and moves them away in a square, otherwise, 4 Actors in a diamondglyph
- the char to make a rotate-able Actor of; should definitely be visiblestartColor
- the color to start the effect withendColor
- the color to end the effect onrotationStrength
- how strongly to rotate the Actors; 0 is no rotation, 1 is a normal rotationduration
- how long, in seconds, the effect should last
-
burst
public void burst(int x, int y, int distance, boolean eightWay, char glyph, com.badlogic.gdx.graphics.Color startColor, com.badlogic.gdx.graphics.Color endColor, float rotationStrength, float duration)Convenience method to produce an explosion, splash, or burst effect. Callssummon(float, int, int, int, int, char, Color, Color, boolean, float, float, float)
repeatedly with different parameters. As with summon(), this creates temporary Actors that change color, position, and rotation. Some parameters need explanation: distance is how many cells away to move the created Actors away from (x,y); eightWay determines whether this produces 4 (cardinal) or 8 (cardinal and diagonal) rotations and directions; rotationStrength can default to 1 if you want some rotation (which looks good) or 0 if you want the Actors to start at the correct rotation and not change that rotation over the course of the effect, but can be between 0 and 1 or higher than 1 (negative values may also work).- Parameters:
x
- the starting, center, x-position to create all Actors aty
- the starting, center, y-position to create all Actors atdistance
- how far away, in cells, to move each actor from the center (Chebyshev distance, forming a square)eightWay
- if true, creates 8 Actors and moves them away in a square, otherwise, 4 Actors in a diamondglyph
- the char to make a rotate-able Actor of; should definitely be visiblestartColor
- the color to start the effect withendColor
- the color to end the effect onrotationStrength
- how strongly to rotate the Actors; 0 is no rotation, 1 is a normal rotationduration
- how long, in seconds, the effect should last
-
burst
public void burst(int x, int y, boolean eightWay, char glyph, com.badlogic.gdx.graphics.Color startColor, com.badlogic.gdx.graphics.Color endColor, boolean doubleWidth, float rotationStrength, float duration)Convenience method to produce an explosion, splash, or burst effect. Callssummon(float, int, int, int, int, char, Color, Color, boolean, float, float, float)
repeatedly with different parameters. As with summon(), this creates temporary Actors that change color, position, and rotation. This overload always moves Actors 1 cell away, which is a safe default. Some parameters need explanation: eightWay determines whether this produces 4 (cardinal) or 8 (cardinal and diagonal) rotations and directions; rotationStrength can default to 1 if you want some rotation (which looks good) or 0 if you want the Actors to start at the correct rotation and not change that rotation over the course of the effect, but can be between 0 and 1 or higher than 1 (negative values may also work).- Parameters:
x
- the starting, center, x-position to create all Actors aty
- the starting, center, y-position to create all Actors ateightWay
- if true, creates 8 Actors and moves them away in a square, otherwise, 4 Actors in a diamondglyph
- the char to make a rotate-able Actor of; should definitely be visiblestartColor
- the color to start the effect withendColor
- the color to end the effect ondoubleWidth
- true if this should use the double-width-cell technique, false in most casesrotationStrength
- how strongly to rotate the Actors; 0 is no rotation, 1 is a normal rotationduration
- how long, in seconds, the effect should last
-
burst
public void burst(int x, int y, int distance, boolean eightWay, char glyph, com.badlogic.gdx.graphics.Color startColor, com.badlogic.gdx.graphics.Color endColor, boolean doubleWidth, float rotationStrength, float duration)Convenience method to produce an explosion, splash, or burst effect. Callssummon(float, int, int, int, int, char, Color, Color, boolean, float, float, float)
repeatedly with different parameters. As with summon(), this creates temporary Actors that change color, position, and rotation. Some parameters need explanation: distance is how many cells away to move the created Actors away from (x,y); eightWay determines whether this produces 4 (cardinal) or 8 (cardinal and diagonal) rotations and directions; rotationStrength can default to 1 if you want some rotation (which looks good) or 0 if you want the Actors to start at the correct rotation and not change that rotation over the course of the effect, but can be between 0 and 1 or higher than 1 (negative values may also work).- Parameters:
x
- the starting, center, x-position to create all Actors aty
- the starting, center, y-position to create all Actors atdistance
- how far away, in cells, to move each actor from the center (Chebyshev distance, forming a square)eightWay
- if true, creates 8 Actors and moves them away in a square, otherwise, 4 Actors in a diamondglyph
- the char to make a rotate-able Actor of; should definitely be visiblestartColor
- the color to start the effect withendColor
- the color to end the effect ondoubleWidth
- true if this should use the double-width-cell technique, false in most casesrotationStrength
- how strongly to rotate the Actors; 0 is no rotation, 1 is a normal rotationduration
- how long, in seconds, the effect should last
-
burst
public void burst(float delay, int x, int y, int distance, boolean eightWay, char glyph, com.badlogic.gdx.graphics.Color startColor, com.badlogic.gdx.graphics.Color endColor, boolean doubleWidth, float rotationStrength, float duration)Convenience method to produce an explosion, splash, or burst effect. Callssummon(float, int, int, int, int, char, Color, Color, boolean, float, float, float)
repeatedly with different parameters. As with summon(), this creates temporary Actors that change color, position, and rotation. Some parameters need explanation: distance is how many cells away to move the created Actors away from (x,y); eightWay determines whether this produces 4 (cardinal) or 8 (cardinal and diagonal) rotations and directions; rotationStrength can default to 1 if you want some rotation (which looks good) or 0 if you want the Actors to start at the correct rotation and not change that rotation over the course of the effect, but can be between 0 and 1 or higher than 1 (negative values may also work).- Parameters:
delay
- amount of time, in seconds, to wait before starting the effectx
- the starting, center, x-position to create all Actors aty
- the starting, center, y-position to create all Actors atdistance
- how far away, in cells, to move each actor from the center (Chebyshev distance, forming a square)eightWay
- if true, creates 8 Actors and moves them away in a square, otherwise, 4 Actors in a diamondglyph
- the char to make a rotate-able Actor of; should definitely be visiblestartColor
- the color to start the effect withendColor
- the color to end the effect ondoubleWidth
- true if this should use the double-width-cell technique, false in most casesrotationStrength
- how strongly to rotate the Actors; 0 is no rotation, 1 is a normal rotationduration
- how long, in seconds, the effect should last
-
hasActiveAnimations
- Specified by:
hasActiveAnimations
in interfaceIPackedColorPanel
- Returns:
- Returns true if there are animations running when this method is called.
-
getAnimatedEntities
-
removeAnimatedEntity
-
getColorCenter
- Returns:
- The current color center. Never
null
.
-
setColorCenter
Use this method if you use your ownIColorCenter
and want this panel not to allocate its own colors (or fillDefaultResources.getSCC()
but instead to the provided center.- Parameters:
scc
- The color center to use. Should not benull
.- Throws:
NullPointerException
- Ifscc
isnull
.
-
getAt
-
getColorAt
-
getLightingColor
-
setLightingColor
-
clampDuration
-
getGridOffsetX
The X offset that the whole panel's internals will be rendered at. If thegridWidth
of this SquidPanel is less than the actual size of the char[][] it renders, then you can use gridOffsetX to start rendering at a different position- Returns:
- the current offset in cells along the x axis
-
setGridOffsetX
Sets the X offset that the whole panel's internals will be rendered at.- Parameters:
gridOffsetX
- the requested offset in cells
-
getGridOffsetY
The Y offset that the whole panel's internals will be rendered at.- Returns:
- the current offset in cells along the y axis
-
setGridOffsetY
Sets the Y offset that the whole panel's internals will be rendered at.- Parameters:
gridOffsetY
- the requested offset in cells
-
getGridWidth
The number of cells along the x-axis that will be rendered of this panel.- Returns:
- the number of cells along the x-axis that will be rendered of this panel
-
setGridWidth
Sets the number of cells along the x-axis that will be rendered of this panel to gridWidth.- Parameters:
gridWidth
- the requested width in cells
-
getGridHeight
The number of cells along the y-axis that will be rendered of this panel- Returns:
- the number of cells along the y-axis that will be rendered of this panel
-
setGridHeight
Sets the number of cells along the y-axis that will be rendered of this panel to gridHeight.- Parameters:
gridHeight
- the requested height in cells
-
getTotalWidth
Gets the total number of cells along the x-axis that this stores; this is usually equivalent togetGridWidth()
, but not if the constructorSquidPanel(int, int, TextCellFactory, IColorCenter, float, float, char[][])
was used to set a larger-than-normal map.- Returns:
- the width of the internal array this can render, which may be larger than the visible width
-
getTotalHeight
Gets the total number of cells along the y-axis that this stores; this is usually equivalent togetGridHeight()
, but not if the constructorSquidPanel(int, int, TextCellFactory, IColorCenter, float, float, char[][])
was used to set a larger-than-normal map.- Returns:
- the height of the internal array this can render, which may be larger than the visible height
-
setPosition
Sets the position of the actor's bottom left corner.- Overrides:
setPosition
in classcom.badlogic.gdx.scenes.scene2d.Actor
- Parameters:
x
-y
-
-
getxOffset
-
setOffsetX
-
getyOffset
-
setOffsetY
-
setOffsets
-
getOnlyRenderEven
Gets the status of a boolean flag used for rendering thin maps; it will almost always be false unless it was set to true withsetOnlyRenderEven(boolean)
.
This is meant for thin-wall maps, where only cells where x and y are both even numbers have backgrounds displayed. Should be false when using this SquidPanel for anything that isn't specifically a background of a map that uses the thin-wall method from ThinDungeonGenerator or something similar. Even the foregrounds of thin-wall maps should have this false, since ThinDungeonGenerator (in conjunction with DungeonUtility's hashesToLines() method) makes thin lines for walls that should be displayed as between the boundaries of other cells. The overlap behavior needed for some "thin enough" cells to be displayed between the cells can be accomplished by usingsetTextSize(float, float)
to double the previously-given cell width and height.- Returns:
- the current status of the onlyRenderEven flag, which defaults to false
-
setOnlyRenderEven
Sets the status of a boolean flag used for rendering thin maps; it should almost always be the default, which is false, unless you are using a thin-wall map, and then this should be true only if this SquidPanel is used for the background layer.
This is meant for thin-wall maps, where only cells where x and y are both even numbers have backgrounds displayed. Should be false when using this SquidPanel for anything that isn't specifically a background of a map that uses the thin-wall method from ThinDungeonGenerator or something similar. Even the foregrounds of thin-wall maps should have this false, since ThinDungeonGenerator (in conjunction with DungeonUtility's hashesToLines() method) makes thin lines for walls that should be displayed as between the boundaries of other cells. The overlap behavior needed for some "thin enough" cells to be displayed between the cells can be accomplished by usingsetTextSize(float, float)
to double the previously-given cell width and height.- Parameters:
onlyRenderEven
- generally, should only be true if this SquidPanel is a background of a thin map
-
getSnapshot
Gets a "snapshot" of the data represented by this SquidPanel; stores the dimensions, the char data, and the color data in a way that can be set back to a SquidPanel usingsetFromSnapshot(String, int, int, int, int)
or its overload that takes a StringBuilder. The actual contents of the returned StringBuilder are unlikely to be legible in any way if read as text, and are meant to be concise and stable across versions.- Returns:
- a StringBuilder representation of this SquidPanel's data that can be passed later to
setFromSnapshot(StringBuilder, int, int, int, int)
or converted to String and passed to its overload
-
getSnapshot
Gets a "snapshot" of the data represented by this SquidPanel; stores the dimensions, the char data, and the color data in a way that can be set back to a SquidPanel usingsetFromSnapshot(String, int, int, int, int)
or its overload that takes a StringBuilder. The actual contents of the returned StringBuilder are unlikely to be legible in any way if read as text, and are meant to be concise and stable across versions. This overload allows the first x and y position used to be specified, as well as the width and height to use (the actual width and height stored may be different if this SquidPanel's gridWidth and/or gridHeight are smaller than the width and/or height given).- Parameters:
startX
- the first x position to use in the snapshot, inclusivestartY
- the first y position to use in the snapshot, inclusivewidth
- how wide the snapshot area should be; x positions from startX to startX + width - 1 will be usedheight
- how tall the snapshot area should be; y positions from startY to startY + height - 1 will be used- Returns:
- a StringBuilder representation of this SquidPanel's data that can be passed later to
setFromSnapshot(StringBuilder, int, int, int, int)
or converted to String and passed to its overload
-
setFromSnapshot
Given a "snapshot" fromgetSnapshot(int, int, int, int)
, this assigns the chars and colors in this SquidPanel from 0,0 (inclusive) up to the dimensions stored in the snapshot to match the snapshot's data.- Parameters:
snapshot
- a StringBuilder in a special format as produced bygetSnapshot(int, int, int, int)
- Returns:
- this after setting, for chaining
-
setFromSnapshot
Given a "snapshot" fromgetSnapshot(int, int, int, int)
, this assigns the chars and colors in this SquidPanel from the position given by putX,putY (inclusive) up to the dimensions stored in the snapshot (considering putX and putY as offsets) so they have the values stored in the snapshot.- Parameters:
snapshot
- a StringBuilder in a special format as produced bygetSnapshot(int, int, int, int)
putX
- where to start placing the data from the snapshot, x positionputY
- where to start placing the data from the snapshot, y position- Returns:
- this after setting, for chaining
-
setFromSnapshot
public SquidPanel setFromSnapshot(StringBuilder snapshot, int putX, int putY, int limitWidth, int limitHeight)Given a "snapshot" fromgetSnapshot(int, int, int, int)
, this assigns the chars and colors in this SquidPanel from the position given by putX,putY (inclusive) to putX+limitWidth,putY+limitHeight (exclusive) so they have the values stored in the snapshot. If limitWidth or limitHeight is negative, this uses the full width and height of the snapshot (stopping early if it would extend past the gridWidth or gridHeight of this SquidPanel).- Parameters:
snapshot
- a StringBuilder in a special format as produced bygetSnapshot(int, int, int, int)
putX
- where to start placing the data from the snapshot, x positionputY
- where to start placing the data from the snapshot, y positionlimitWidth
- if negative, uses all of snapshot's width as possible, otherwise restricts the width allowedlimitHeight
- if negative, uses all of snapshot's height as possible, otherwise restricts the height allowed- Returns:
- this after setting, for chaining
-
setFromSnapshot
Given a "snapshot" fromgetSnapshot(int, int, int, int)
, this assigns the chars and colors in this SquidPanel from 0,0 (inclusive) up to the dimensions stored in the snapshot to match the snapshot's data.
This overload takes a String instead of a StringBuilder for potentially-easier loading from files.- Parameters:
snapshot
- a String in a special format as produced bygetSnapshot(int, int, int, int)
- Returns:
- this after setting, for chaining
-
setFromSnapshot
Given a "snapshot" fromgetSnapshot(int, int, int, int)
, this assigns the chars and colors in this SquidPanel from the position given by putX,putY (inclusive) up to the dimensions stored in the snapshot (considering putX and putY as offsets) so they have the values stored in the snapshot.
This overload takes a String instead of a StringBuilder for potentially-easier loading from files.- Parameters:
snapshot
- a String in a special format as produced bygetSnapshot(int, int, int, int)
putX
- where to start placing the data from the snapshot, x positionputY
- where to start placing the data from the snapshot, y position- Returns:
- this after setting, for chaining
-
setFromSnapshot
public SquidPanel setFromSnapshot(String snapshot, int putX, int putY, int limitWidth, int limitHeight)Given a "snapshot" fromgetSnapshot(int, int, int, int)
, this assigns the chars and colors in this SquidPanel from the position given by putX,putY (inclusive) to putX+limitWidth,putY+limitHeight (exclusive) so they have the values stored in the snapshot. If limitWidth or limitHeight is negative, this uses the full width and height of the snapshot (stopping early if it would extend past the gridWidth or gridHeight of this SquidPanel).
This overload takes a String instead of a StringBuilder for potentially-easier loading from files.- Parameters:
snapshot
- a String in a special format as produced bygetSnapshot(int, int, int, int)
putX
- where to start placing the data from the snapshot, x positionputY
- where to start placing the data from the snapshot, y positionlimitWidth
- if negative, uses all of snapshot's width as possible, otherwise restricts the width allowedlimitHeight
- if negative, uses all of snapshot's height as possible, otherwise restricts the height allowed- Returns:
- this after setting, for chaining
-