public abstract class Sequence
extends java.lang.Object
Keyboard
, Mouse
), and it includes a
standard game loop (update(double)
and render(Graphic)
), synchronized to a
specified frame rate.
Here a blank sequence implementation:
final class Scene extends Sequence { private static final Resolution NATIVE = new Resolution(320, 240, 60); Scene(Loader loader) { super(loader, Scene.NATIVE); } @Override protected void load() { // Load } @Override protected void update(double extrp) { if (keyboard.isPressed(Key.ESCAPE)) { end(); } // Update } @Override protected void render(Graphic g) { // Render } }
Loader
,
Resolution
,
Graphic
Constructor and Description |
---|
Sequence(Loader loader,
Resolution newSource)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addKeyListener(KeyboardListener listener)
Add a key listener.
|
void |
end()
Terminate sequence, close screen, and start launcher if exists.
|
void |
end(Sequence nextSequence)
Terminate sequence, and set the next sequence.
|
Config |
getConfig()
Get the configuration.
|
int |
getFps()
Get current frame rate (number of image per second).
|
Keyboard |
getKeyboard()
Get the keyboard reference.
|
Mouse |
getMouse()
Get the mouse reference.
|
void |
setExtrapolated(boolean extrapolated)
Set the extrapolation flag.
|
void |
setMouseVisible(boolean visible)
Set the mouse visibility.
|
void |
start(Sequence nextSequence,
boolean wait)
Start the next sequence, call the
load() function, and wait for current sequence to end before next
sequence continues. |
public Sequence(Loader loader, Resolution newSource)
loader
- The loader reference.newSource
- The resolution source reference.public final void end()
public final void end(Sequence nextSequence)
nextSequence
- The next sequence reference.public final void start(Sequence nextSequence, boolean wait)
load()
function, and wait for current sequence to end before next
sequence continues. This function should be used to synchronize two sequences (eg: load a next sequence while
being in a menu). Do not forget to call end()
in order to give control to the next sequence. The next
sequence should override onLoaded(double, Graphic)
for special load just before enter in the loop.nextSequence
- The next sequence reference.wait
- true
to wait for the next sequence to be loaded, false
else.public final void addKeyListener(KeyboardListener listener)
listener
- The listener to add.public final void setMouseVisible(boolean visible)
visible
- The visibility state.public final void setExtrapolated(boolean extrapolated)
extrapolated
- true
will activate it, false
will disable it.public final int getFps()
public Config getConfig()
public Keyboard getKeyboard()
public Mouse getMouse()