Class SpeechBubble
java.lang.Object
de.gurkenlabs.litiengine.gui.GuiComponent
de.gurkenlabs.litiengine.gui.SpeechBubble
- All Implemented Interfaces:
IRenderable,IUpdateable,Tweenable,MouseListener,MouseMotionListener,MouseWheelListener,EventListener
A SpeechBubble is a GuiComponent with a given text that is pinned to an entity and moves with it. After initializing
the speech bubble, you can start it separately, which will add the component to the current screen, register it for
updates and make it visible on screen. Stopping the speech bubble will remove the component and deregister its
updates.
-
Field Summary
Fields inherited from class de.gurkenlabs.litiengine.gui.GuiComponent
ICON_FONT -
Constructor Summary
ConstructorsConstructorDescriptionSpeechBubble(IEntity entity, double width, double height, int displayTime, String text) Instantiates a new Speech bubble.SpeechBubble(IEntity entity, String text) Instantiates a new speech bubble. -
Method Summary
Modifier and TypeMethodDescriptionGets the horizontal speech bubble alignment that dictates its position relative to the entity center point.intGets the duration in milliseconds for which this speech bubble will be active.Gets the entity to which this speech bubble is pinned.Gets the total text that this Speech bubble will display.Gets the triangle indicator's shape, translated to the correct location on screen.doubleGets the triangle indicator size.intGets type delay, which determines how fast the typewriter effect will be.Gets the sound that is played every time a new letter appears.booleanChecks if the triangle indicator is active.voidrender(Graphics2D g) Note: If you override this and are modifying swing components, be sure you are in the AWT thread when you do so!voidsetBoxAlign(Align boxAlign) Sets the horizontal speech bubble alignment that dictates its position relative to the entity center point.voidsetDisplayTime(int displayTime) Sets the duration in milliseconds for which this speech bubble will be active.voidsetHeight(double height) Sets the GuiComponent's height.voidsetLocation(Point2D location) Sets this GuiComponent's location.voidsetRenderTriangle(boolean renderTriangle) Sets the visibility status of the triangle indicator.voidsetTriangleSize(double triangleSize) Gets the triangle indicator size.voidsetTypeDelay(int typeDelay) Sets type delay, which determines how fast the typewriter effect will be.voidsetTypeSound(Sound typeSound) Sets the sound that is played every time a new letter appears.voidsetWidth(double width) Sets the GuiComponent's width.voidstart()Start the speech bubble.voidstop()Stop the speech bubble.voidupdate()This method is called by the game loop on all objects that are attached to the loop.Methods inherited from class de.gurkenlabs.litiengine.gui.GuiComponent
addRenderedListener, addRenderListener, getAppearance, getAppearanceDisabled, getAppearanceHovered, getBoundingBox, getCenterX, getCenterY, getClickConsumer, getComponentId, getComponents, getCurrentAppearance, getFont, getHeight, getHoverConsumer, getHoverSound, getLocation, getMouseDraggedConsumer, getMouseEnterConsumer, getMouseLeaveConsumer, getMouseMovedConsumer, getMousePressedConsumer, getMouseReleasedConsumer, getMouseWheelConsumer, getName, getShape, getTag, getText, getTextAlign, getTextAngle, getTextShadowColor, getTextShadowRadius, getTextToRender, getTextValign, getTextX, getTextY, getTweenValues, getWidth, getX, getY, hasAutomaticLineBreaks, hasTextAntialiasing, hasTextShadow, initializeComponents, isEnabled, isForwardMouseEvents, isHovered, isPressed, isSelected, isSuspended, isVisible, mouseClicked, mouseDragged, mouseEntered, mouseEventShouldBeForwarded, mouseExited, mouseMoved, mousePressed, mouseReleased, mouseWheelMoved, onClicked, onHovered, onMouseDragged, onMouseEnter, onMouseLeave, onMouseMoved, onMousePressed, onMouseReleased, onMouseWheelScrolled, onTextChanged, prepare, removeListener, removeListener, setAutomaticLineBreaks, setDimension, setEnabled, setFont, setFontSize, setForwardMouseEvents, setHovered, setHoverSound, setLocation, setName, setSelected, setTag, setText, setTextAlign, setTextAngle, setTextAntialiasing, setTextShadow, setTextShadowColor, setTextShadowRadius, setTextValign, setTextX, setTextY, setTweenValues, setVisible, setX, setY, suspend, toggleSelection, toggleSuspension
-
Constructor Details
-
SpeechBubble
-
SpeechBubble
Instantiates a new Speech bubble.- Parameters:
entity- the entity to which the Speech bubble will be pinnedwidth- the width of the text boxheight- the height of the text boxdisplayTime- the display time in millisecondstext- the text which will appear in the speech bubble
-
-
Method Details
-
getEntity
Gets the entity to which this speech bubble is pinned.- Returns:
- the entity
-
getDisplayTime
public int getDisplayTime()Gets the duration in milliseconds for which this speech bubble will be active.- Returns:
- the display time in milliseconds
-
setDisplayTime
public void setDisplayTime(int displayTime) Sets the duration in milliseconds for which this speech bubble will be active.- Parameters:
displayTime- the display time in milliseconds
-
start
public void start()Start the speech bubble. This will add it to the current Screen's components, make it visible and register it for updates in the Game loop. After the display time has elapsed, the speech bubble will be stopped automatically. -
stop
public void stop()Stop the speech bubble. This will remove it from the current Screen's components, make it invisible and deregister it from updates in the Game loop. -
render
Description copied from class:GuiComponentNote: If you override this and are modifying swing components, be sure you are in the AWT thread when you do so!- Specified by:
renderin interfaceIRenderable- Overrides:
renderin classGuiComponent- Parameters:
g- The current graphics object onto which this instance will render its visual contents.- See Also:
-
getBoxAlign
Gets the horizontal speech bubble alignment that dictates its position relative to the entity center point.- Returns:
- the box Align
-
setBoxAlign
Sets the horizontal speech bubble alignment that dictates its position relative to the entity center point.- Parameters:
boxAlign- the box Align
-
update
public void update()Description copied from interface:IUpdateableThis method is called by the game loop on all objects that are attached to the loop. It's called on every tick of the loop and the frequency can be configured using theClientConfiguration.- Specified by:
updatein interfaceIUpdateable- See Also:
-
isRenderingTriangle
public boolean isRenderingTriangle()Checks if the triangle indicator is active.- Returns:
- true, if the speech bubble is rendering a triangle indicator on the bottom.
-
setRenderTriangle
public void setRenderTriangle(boolean renderTriangle) Sets the visibility status of the triangle indicator.- Parameters:
renderTriangle- if true, the triangle will be visible.
-
setLocation
Description copied from class:GuiComponentSets this GuiComponent's location.- Overrides:
setLocationin classGuiComponent- Parameters:
location- the new location
-
setWidth
public void setWidth(double width) Description copied from class:GuiComponentSets the GuiComponent's width.- Overrides:
setWidthin classGuiComponent- Parameters:
width- the new width
-
setHeight
public void setHeight(double height) Description copied from class:GuiComponentSets the GuiComponent's height.- Overrides:
setHeightin classGuiComponent- Parameters:
height- the new height
-
getTriangle
Gets the triangle indicator's shape, translated to the correct location on screen.- Returns:
- A Path2D object representing the triangle indicator.
-
getTriangleSize
public double getTriangleSize()Gets the triangle indicator size. Its size is identical for width and height.- Returns:
- the triangle indicator size
-
setTriangleSize
public void setTriangleSize(double triangleSize) Gets the triangle indicator size. Its size is identical for width and height.- Parameters:
triangleSize- the new triangle indicator size
-
getTypeDelay
public int getTypeDelay()Gets type delay, which determines how fast the typewriter effect will be.- Returns:
- the type delay in milliseconds
-
setTypeDelay
public void setTypeDelay(int typeDelay) Sets type delay, which determines how fast the typewriter effect will be.- Parameters:
typeDelay- the type delay in milliseconds
-
getTypeSound
Gets the sound that is played every time a new letter appears.- Returns:
- the type sound
-
setTypeSound
Sets the sound that is played every time a new letter appears.- Parameters:
typeSound- the type sound
-
getTotalText
Gets the total text that this Speech bubble will display.- Returns:
- the total text
-