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

public class SpeechBubble extends GuiComponent implements IUpdateable
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.
  • Constructor Details

    • SpeechBubble

      public SpeechBubble(IEntity entity, String text)
      Instantiates a new speech bubble.
      Parameters:
      entity - the entity to which the Speech bubble will be pinned
      text - the text which will appear in the speech bubble
    • SpeechBubble

      public SpeechBubble(IEntity entity, double width, double height, int displayTime, String text)
      Instantiates a new Speech bubble.
      Parameters:
      entity - the entity to which the Speech bubble will be pinned
      width - the width of the text box
      height - the height of the text box
      displayTime - the display time in milliseconds
      text - the text which will appear in the speech bubble
  • Method Details

    • getEntity

      public IEntity 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

      public void render(Graphics2D g)
      Description copied from class: GuiComponent
      Note: If you override this and are modifying swing components, be sure you are in the AWT thread when you do so!
      Specified by:
      render in interface IRenderable
      Overrides:
      render in class GuiComponent
      Parameters:
      g - The current graphics object onto which this instance will render its visual contents.
      See Also:
    • getBoxAlign

      public Align getBoxAlign()
      Gets the horizontal speech bubble alignment that dictates its position relative to the entity center point.
      Returns:
      the box Align
    • setBoxAlign

      public void setBoxAlign(Align boxAlign)
      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: IUpdateable
      This 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 the ClientConfiguration.
      Specified by:
      update in interface IUpdateable
      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

      public void setLocation(Point2D location)
      Description copied from class: GuiComponent
      Sets this GuiComponent's location.
      Overrides:
      setLocation in class GuiComponent
      Parameters:
      location - the new location
    • setWidth

      public void setWidth(double width)
      Description copied from class: GuiComponent
      Sets the GuiComponent's width.
      Overrides:
      setWidth in class GuiComponent
      Parameters:
      width - the new width
    • setHeight

      public void setHeight(double height)
      Description copied from class: GuiComponent
      Sets the GuiComponent's height.
      Overrides:
      setHeight in class GuiComponent
      Parameters:
      height - the new height
    • getTriangle

      public Path2D 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

      public Sound getTypeSound()
      Gets the sound that is played every time a new letter appears.
      Returns:
      the type sound
    • setTypeSound

      public void setTypeSound(Sound typeSound)
      Sets the sound that is played every time a new letter appears.
      Parameters:
      typeSound - the type sound
    • getTotalText

      public String getTotalText()
      Gets the total text that this Speech bubble will display.
      Returns:
      the total text