Class ScreenSpace

java.lang.Object
tripleplay.game.ScreenSpace
All Implemented Interfaces:
Iterable<ScreenSpace.Screen>

public class ScreenSpace extends Object implements Iterable<ScreenSpace.Screen>
Maintains a 2D layout of ScreenSpace.Screens. New screens can be introduced in a direction, and the view is scrolled in that direction to focus on the new screen. The user can then slide the view back toward the previous screen (in the opposite direction that it was introduced). If they release their slide with the old screen sufficiently visible, it will be restored to focus.
  • Field Details

  • Constructor Details

    • ScreenSpace

      public ScreenSpace(Game game, GroupLayer rootLayer)
      Creates a screen space which will manage screens for game.
  • Method Details

    • iterator

      public Iterator<ScreenSpace.Screen> iterator()
      Specified by:
      iterator in interface Iterable<ScreenSpace.Screen>
    • screenCount

      public int screenCount()
      Returns the number of screens in the space.
    • screen

      public ScreenSpace.Screen screen(int index)
      Returns the screen at index.
    • focus

      public ScreenSpace.Screen focus()
      Returns the currently focused screen.
    • isTransiting

      public boolean isTransiting()
      Returns true if we're transitioning between two screens at this instant. This may either be an animation driven transition, or a manual transition in progress due to a user drag.
    • transPct

      public float transPct()
      Returns the degree of completeness ([0,1]) of any in-progress transition, or 0.
    • target

      public ScreenSpace.Screen target()
      Returns the target screen in the current transition, or null.
    • initAdd

      public void initAdd(ScreenSpace.Screen screen, ScreenSpace.Dir dir)
      Adds screen to this space but does not activate or wake it. This is intended for prepopulation of a screenstack at app start. This method must not be called once the stack is in normal operation. A series of calls to initAdd must be followed by one call to add(tripleplay.game.ScreenSpace.Screen, tripleplay.game.ScreenSpace.Dir) with the screen that is actually to be displayed at app start.
    • add

      public void add(ScreenSpace.Screen screen, ScreenSpace.Dir dir)
      Adds screen to this space, positioned dir-wise from the current screen. For example, using RIGHT will add the screen to the right of the current screen and will slide the view to the right to reveal the new screen. The user would then manually slide the view left to return to the previous screen.
    • replace

      public void replace(ScreenSpace.Screen screen)
      Adds screen to this space, replacing the current top-level screen. The screen is animated in the same manner as add(tripleplay.game.ScreenSpace.Screen, tripleplay.game.ScreenSpace.Dir) using the same direction in which the current screen was added. This ensures that the user returns to the previous screen in the same way that they would via the to-be-replaced screen.
    • pop

      public void pop(ScreenSpace.Screen screen)
      Removes screen from this space. If it is the top-level screen, an animated transition to the previous screen will be performed. Otherwise the screen will simply be removed.
    • popTo

      public void popTo(ScreenSpace.Screen screen)
      Removes all screens from the space until screen is reached. No transitions will be used, all screens will simply be removed and disposed until we reach screen, and that screen will be woken and positioned properly.
    • current

      public ScreenSpace.Screen current()
      Returns the current screen, or null if this space is empty.
    • bottom

      public ScreenSpace.Screen bottom()
      Returns the lowest screen in the stack.