Class StatsAppState

All Implemented Interfaces:

public class StatsAppState extends AbstractAppState
Displays stats in SimpleApplication's GUI node or using the node and font parameters provided.
  • Field Details

    • statsView

      protected StatsView statsView
    • showSettings

      protected boolean showSettings
    • guiNode

      protected Node guiNode
    • secondCounter

      protected float secondCounter
    • frameCounter

      protected int frameCounter
    • fpsText

      protected BitmapText fpsText
    • guiFont

      protected BitmapFont guiFont
    • darkenFps

      protected Geometry darkenFps
    • darkenStats

      protected Geometry darkenStats
  • Constructor Details

    • StatsAppState

      public StatsAppState()
    • StatsAppState

      public StatsAppState(Node guiNode, BitmapFont guiFont)
  • Method Details

    • setFont

      public void setFont(BitmapFont guiFont)
      Called by SimpleApplication to provide an early font so that the fpsText can be created before init. This is because several applications expect to directly access fpsText... unfortunately.
      guiFont - the desired font (not null, alias created)
    • getFpsText

      public BitmapText getFpsText()
    • getStatsView

      public StatsView getStatsView()
    • getSecondCounter

      public float getSecondCounter()
    • toggleStats

      public void toggleStats()
    • setDisplayFps

      public void setDisplayFps(boolean show)
    • setDisplayStatView

      public void setDisplayStatView(boolean show)
    • setDarkenBehind

      public void setDarkenBehind(boolean darkenBehind)
    • isDarkenBehind

      public boolean isDarkenBehind()
    • initialize

      public void initialize(AppStateManager stateManager, Application app)
      Description copied from interface: AppState
      Called by AppStateManager when transitioning this AppState from initializing to running.
      This will happen on the next iteration through the update loop after AppStateManager.attach( was called.

      AppStateManager will call this only from the update loop inside the rendering thread. This means is it safe to modify the scene graph from this method.

      Specified by:
      initialize in interface AppState
      initialize in class AbstractAppState
      stateManager - The state manager
      app - The application
    • loadFpsText

      public void loadFpsText()
      Attaches FPS statistics to guiNode and displays it on the screen.
    • loadStatsView

      public void loadStatsView()
      Attaches Statistics View to guiNode and displays it on the screen above FPS statistics line.
    • loadDarken

      public void loadDarken()
    • setEnabled

      public void setEnabled(boolean enabled)
      Description copied from interface: AppState
      Enable or disable the functionality of the AppState. The effect of this call depends on implementation. An AppState starts as being enabled by default. A disabled AppStates does not get calls to AppState.update(float), AppState.render(RenderManager), or AppState.postRender() from its AppStateManager.
      Specified by:
      setEnabled in interface AppState
      setEnabled in class AbstractAppState
      enabled - activate the AppState or not.
    • update

      public void update(float tpf)
      Description copied from interface: AppState
      Called to update the AppState. This method will be called every render pass if the AppState is both attached and enabled.
      Specified by:
      update in interface AppState
      update in class AbstractAppState
      tpf - Time since the last call to update(), in seconds.
    • cleanup

      public void cleanup()
      Description copied from interface: AppState
      Called by AppStateManager when transitioning this AppState from terminating to detached. This method is called the following render pass after the AppState has been detached and is always called once and only once for each time initialize() is called. Either when the AppState is detached or when the application terminates (if it terminates normally).
      Specified by:
      cleanup in interface AppState
      cleanup in class AbstractAppState