Class ScreenSpace.Screen

java.lang.Object
tripleplay.game.ScreenSpace.Screen
Direct Known Subclasses:
ScreenSpace.UIScreen
Enclosing class:
ScreenSpace

public abstract static class ScreenSpace.Screen extends Object
A screen that integrates with ScreenSpace. The screen lifecycle is: init [wake gainedFocus lostFocus sleep]+ dispose.

When the screen has the potential to become visible (due to the user scrolling part of the screen into view) it will have been wakened. If the user selects the screen, it will be animated into position and then gainedFocus will be called. If the user scrolls a new screen into view, lostFocus will be called, the screen will be animated away. If the screen is no longer "at risk" of being shown, sleep will be called. When the screen is finally removed from the screen space, dispose will be called.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    Contains the scene graph root for this screen.
    final react.Signal<Clock>
    A signal emitted on every frame, while this screen is showing.
    final react.Signal<Clock>
    A signal emitted on every simulation update, while this screen is showing.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Screen(Game game)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Returns true when this screen is awake.
    boolean
    Returns whether or not an untransition gesture may be initiated via dir.
    void
    Adds ac to a list of closeables which will be closed when this screen goes to sleep.
    void
    Called when this screen is removed from the screen space.
    void
    Called when this screen has become the active screen.
    void
    Called when this screen is first added to the screen space.
    void
    Called when some other screen is about to become the active screen.
    pythagoras.f.IDimension
    Returns the size of this screen, for use by transitions.
    react.ValueView<pythagoras.f.IDimension>
    The size of this screen as a reactive value.
    void
    Called when this screen is no longer at risk of being seen by the user.
     
    boolean
    Returns true when this screen is in-transition.
    void
    Called when this screen will potentially be shown.

    Methods inherited from class java.lang.Object

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

    • layer

      public final GroupLayer layer
      Contains the scene graph root for this screen.
    • update

      public final react.Signal<Clock> update
      A signal emitted on every simulation update, while this screen is showing.
    • paint

      public final react.Signal<Clock> paint
      A signal emitted on every frame, while this screen is showing.
  • Constructor Details

    • Screen

      public Screen(Game game)
  • Method Details

    • init

      public void init()
      Called when this screen is first added to the screen space.
    • size

      public pythagoras.f.IDimension size()
      Returns the size of this screen, for use by transitions. Defaults to the size of the entire view.
    • sizeValue

      public react.ValueView<pythagoras.f.IDimension> sizeValue()
      The size of this screen as a reactive value. Listeners are notified when the screen size changes.
    • awake

      public boolean awake()
      Returns true when this screen is awake.
    • transiting

      public boolean transiting()
      Returns true when this screen is in-transition.
    • wake

      public void wake()
      Called when this screen will potentially be shown. Should create main UI and prepare it for display.
    • gainedFocus

      public void gainedFocus()
      Called when this screen has become the active screen.
    • lostFocus

      public void lostFocus()
      Called when some other screen is about to become the active screen. This screen will be animated out of view. This may not be immediately followed by a call to sleep() because the screen may remain visible due to incidental scrolling by the user. Only when the screen is separated from the focus screen by at least one screen will it be put to sleep.
    • sleep

      public void sleep()
      Called when this screen is no longer at risk of being seen by the user. This should dispose the UI and minimize the screen's memory footprint as much as possible.
    • dispose

      public void dispose()
      Called when this screen is removed from the screen space. This will always be preceded by a call to sleep(), but if there are any resources that the screen retains until it is completely released, this is the place to remove them.
    • canUntrans

      public boolean canUntrans(ScreenSpace.Dir dir)
      Returns whether or not an untransition gesture may be initiated via dir.

      By default this requires that the screen be at its origin in x or y depending on the orientation of dir. If a screen uses a Flicker to scroll vertically, this will automatically do the right thing. If there are other circumstances in which a screen wishes to prevent the user from initiating an untransition gesture, this is the place to put 'em.

    • closeOnSleep

      public void closeOnSleep(AutoCloseable ac)
      Adds ac to a list of closeables which will be closed when this screen goes to sleep.
    • toString

      public String toString()
      Overrides:
      toString in class Object