Package tripleplay.game
Class ScreenSpace
java.lang.Object
tripleplay.game.ScreenSpace
- All Implemented Interfaces:
Iterable<ScreenSpace.Screen>
Maintains a 2D layout of
ScreenSpace.Screen
s. 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.-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
The directions in which a new screen can be added.static class
A screen that integrates withScreenSpace
.static class
AScreenSpace.Screen
that takes care of basic UI setup for you. -
Field Summary
Modifier and TypeFieldDescriptionstatic final ScreenSpace.Dir
static final ScreenSpace.Dir
static final ScreenSpace.Dir
static final ScreenSpace.Dir
static final ScreenSpace.Dir
static final ScreenSpace.Dir
static final ScreenSpace.Dir
-
Constructor Summary
ConstructorDescriptionScreenSpace
(Game game, GroupLayer rootLayer) Creates a screen space which will manage screens forgame
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(ScreenSpace.Screen screen, ScreenSpace.Dir dir) Addsscreen
to this space, positioneddir
-wise from the current screen.bottom()
Returns the lowest screen in the stack.current()
Returns the current screen, ornull
if this space is empty.focus()
Returns the currently focused screen.void
initAdd
(ScreenSpace.Screen screen, ScreenSpace.Dir dir) Addsscreen
to this space but does not activate or wake it.boolean
Returns true if we're transitioning between two screens at this instant.iterator()
void
pop
(ScreenSpace.Screen screen) Removesscreen
from this space.void
popTo
(ScreenSpace.Screen screen) Removes all screens from the space untilscreen
is reached.void
replace
(ScreenSpace.Screen screen) Addsscreen
to this space, replacing the current top-level screen.screen
(int index) Returns the screen atindex
.int
Returns the number of screens in the space.target()
Returns the target screen in the current transition, or null.float
transPct()
Returns the degree of completeness ([0,1]
) of any in-progress transition, or 0.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
UP
-
DOWN
-
LEFT
-
RIGHT
-
IN
-
OUT
-
FLIP
-
-
Constructor Details
-
ScreenSpace
Creates a screen space which will manage screens forgame
.
-
-
Method Details
-
iterator
- Specified by:
iterator
in interfaceIterable<ScreenSpace.Screen>
-
screenCount
public int screenCount()Returns the number of screens in the space. -
screen
Returns the screen atindex
. -
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
Returns the target screen in the current transition, or null. -
initAdd
Addsscreen
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 toinitAdd
must be followed by one call toadd(tripleplay.game.ScreenSpace.Screen, tripleplay.game.ScreenSpace.Dir)
with the screen that is actually to be displayed at app start. -
add
Addsscreen
to this space, positioneddir
-wise from the current screen. For example, usingRIGHT
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
Addsscreen
to this space, replacing the current top-level screen. The screen is animated in the same manner asadd(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
Removesscreen
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
Removes all screens from the space untilscreen
is reached. No transitions will be used, all screens will simply be removed and disposed until we reachscreen
, and that screen will be woken and positioned properly. -
current
Returns the current screen, ornull
if this space is empty. -
bottom
Returns the lowest screen in the stack.
-