T
- The type of colorpublic abstract class AbstractSquidScreen<T extends com.badlogic.gdx.graphics.Color> extends com.badlogic.gdx.ScreenAdapter
ScreenAdapter
. This is a
very general implementation (on which I rely in my game), please do not
change that too radically.
By implementing getNext()
, you specify how to switch between screens
(for example: splash screen -> (main menu screen <-> game screen)). To build
your SquidPanel
, you should use the protected methods that this class
provides. In this way, you won't have to worry about the screen size and
resizes.
Moving from a screen to another is either triggered by libgdx (when it calls
resize(int, int)
and dispose()
) or by you (you can call
dispose()
directly). In both cases, it'll make
SquidApplicationAdapter
's
ApplicationAdapter.render()
method call
getNext()
, hereby triggering screen change.
There really is now way around this class being abstract. Very often, the
result of getNext()
cannot be precomputed. For example after a game
screen, either you'll go to the win screen or the loose screen. And the
latters cannot be precomputed when building the game screen :-(
Modifier and Type | Class and Description |
---|---|
static class |
AbstractSquidScreen.SquidScreenInput<T>
A dumb container, to avoid having too many parameters to
AbstractSquidScreen 's constructor. |
Modifier and Type | Field and Description |
---|---|
protected squidpony.IColorCenter<T> |
colorCenter |
protected boolean |
disposed |
protected IPanelBuilder |
ipb |
protected boolean |
resized |
protected ScreenSizeManager |
sizeManager
The current size manager.
|
protected com.badlogic.gdx.scenes.scene2d.Stage |
stage
It is up to subclassers to initialize this field.
|
Constructor and Description |
---|
AbstractSquidScreen(AbstractSquidScreen.SquidScreenInput<T> ssi)
Here's what the content of
ssi must be:
A size manager that is correct w.r.t. |
Modifier and Type | Method and Description |
---|---|
protected SquidPanel |
buildScreenWideSquidPanel() |
protected SquidPanel |
buildScreenWideSquidPanel(int desiredCellSize) |
protected SquidPanel |
buildSquidPanel(int width,
int height) |
protected SquidPanel |
buildSquidPanel(int width,
int height,
int cellWidth,
int cellHeight) |
protected com.badlogic.gdx.scenes.scene2d.Stage |
buildStage() |
protected void |
clearScreen() |
void |
dispose() |
protected boolean |
disposeAtResize() |
protected T |
getClearingColor() |
abstract AbstractSquidScreen<T> |
getNext()
|
IPanelBuilder |
getPanelbuilder()
Ideally, you should always go through this method to create a
SquidPanel . |
boolean |
hasPendingResize() |
boolean |
isDisposed() |
void |
resize(int width,
int height) |
AbstractSquidScreen.SquidScreenInput<T> |
toSquidScreenInput() |
protected ScreenSizeManager sizeManager
resize(int, int)
has been
done by libgdx, and getNext()
wasn't called yet.protected final squidpony.IColorCenter<T extends com.badlogic.gdx.graphics.Color> colorCenter
protected final IPanelBuilder ipb
protected com.badlogic.gdx.scenes.scene2d.Stage stage
dispose()
. Usually it is assigned at construction
time or in ScreenAdapter.render(float)
.protected boolean disposed
protected boolean resized
public AbstractSquidScreen(AbstractSquidScreen.SquidScreenInput<T> ssi)
ssi
must be:
Gdx.graphics
) and a cell size you want.
The screen's size is not computed automatically by this constructor,
because usually you can build a single instance of
ScreenSizeManager
at startup, and pass it along all
AbstractSquidScreen
. The instance will only change when there's
some resizing (i.e. when ligdx calls
ScreenAdapter.resize(int, int)
).
SquidPanel
.public void dispose()
dispose
in interface com.badlogic.gdx.Screen
dispose
in class com.badlogic.gdx.ScreenAdapter
public void resize(int width, int height)
resize
in interface com.badlogic.gdx.Screen
resize
in class com.badlogic.gdx.ScreenAdapter
public abstract AbstractSquidScreen<T> getNext()
disposed
and resized
. When resized
holds, this method typically
returns an instance that is a variation of this
, where the font
size has been changed (to get the new size, use sizeManager
; it
has been updated already). When disposed
holds, the usual
behavior is for this method to return null to quit the whole application
(that's the assumption that
SquidApplicationAdapter
does) or to
return another screen to move forward (for example when switching from
the main/splash screen to the game's screen).
This method is normally called when the user is moving to the next screen
(so that's your game logic) or when isDisposed()
holds or when
hasPendingResize()
holds.
null
if the
application is quitting.public boolean isDisposed()
dispose()
on this
.public boolean hasPendingResize()
resize(int, int)
on this
.public IPanelBuilder getPanelbuilder()
SquidPanel
.SquidPanel
.public AbstractSquidScreen.SquidScreenInput<T> toSquidScreenInput()
AbstractSquidScreen
from this
's content.protected final SquidPanel buildScreenWideSquidPanel(int desiredCellSize)
desiredCellSize
- protected final SquidPanel buildScreenWideSquidPanel()
protected final SquidPanel buildSquidPanel(int width, int height)
width
- height
- (width, height)
that uses the default
cell width/cell height. Its position isn't set.protected final SquidPanel buildSquidPanel(int width, int height, int cellWidth, int cellHeight)
width
- height
- cellWidth
- cellHeight
- (width, height)
that has cellSize
. Its position isn't set.protected com.badlogic.gdx.scenes.scene2d.Stage buildStage()
protected boolean disposeAtResize()
protected T getClearingColor()
clearScreen()
(used in this class when moving from a
AbstractSquidScreen
to another).protected void clearScreen()
Copyright © 2012–2016. All rights reserved.