Class Hud

java.lang.Object
tripleplay.util.Hud
Direct Known Subclasses:
Hud.Stock

public class Hud extends Object
Maintains a (usually debugging) HUD with textual information displayed in one or two columns. The text is all rendered to a single Canvas (and updated only when values change) to put as little strain on the renderer as possible. Example usage:

 class MyGame extends SceneGame {
   private Hud.Stock hud = new Hud.Stock(this);
   public void init () {
     hud.layer.setDepth(Short.MAX_VALUE);
     rootLayer.add(hud.layer);
   }
 }
 
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    A stock HUD that provides a bunch of standard PlayN performance info and handles once-per-second updating.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    The layer that contains this HUD.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Hud(SceneGame game)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(String label, boolean header)
    Adds a static label that spans the width of the HUD.
    void
    add(String label, react.Value<?> value)
    Adds a static label and changing value, which will be rendered in two columns.
    void
    add(react.Value<?> label)
    Adds a changing label that spans the width of the HUD.
    setColors(int textColor, int bgColor)
    Configures the foreground and background colors.
    setFont(Font font)
    Configures the font used to display the HUD.
    void
    Updates the HUDs rendered image.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • layer

      public final CanvasLayer layer
      The layer that contains this HUD. Add to the scene graph where desired.
  • Constructor Details

  • Method Details

    • setFont

      public Hud setFont(Font font)
      Configures the font used to display the HUD. Must be called before adding rows.
    • setColors

      public Hud setColors(int textColor, int bgColor)
      Configures the foreground and background colors. Must be called before adding rows.
    • add

      public void add(String label, boolean header)
      Adds a static label that spans the width of the HUD.
    • add

      public void add(react.Value<?> label)
      Adds a changing label that spans the width of the HUD.
    • add

      public void add(String label, react.Value<?> value)
      Adds a static label and changing value, which will be rendered in two columns.
    • update

      public void update()
      Updates the HUDs rendered image. Call this after all of its values have been updated (usually once per second).