public abstract class Sequence extends Object implements Sequencable, ScreenListener
getInputDevice(Class)
), and it includes
a standard game loop (Updatable.update(double)
and Renderable.render(Graphic)
), synchronized to a specified frame rate.
Here a blank sequence implementation:
public class MySequence extends Sequence { private static final Resolution NATIVE = new Resolution(320, 240, 60); public MySequence(Context context) { super(context, MySequence.NATIVE); // Initialize variables here } @Override public void load() { // Load resources here } @Override public void update(double extrp) { // Update routine } @Override public void render(Graphic g) { // Render routine } }
This class is Thread-Safe.
Loader
,
Resolution
,
InputDevice
Constructor and Description |
---|
Sequence(Context context,
Resolution resolution)
Constructor base.
|
Modifier and Type | Method and Description |
---|---|
void |
addKeyListener(InputDeviceKeyListener listener)
Add a key listener.
|
void |
end()
Terminate sequence.
|
void |
end(Class<? extends Sequencable> nextSequenceClass,
Object... arguments)
Terminate sequence, and set the next sequence.
|
Config |
getConfig()
Get the configuration.
|
int |
getFps()
Get current frame rate (number of image per second).
|
protected int |
getHeight()
Get the rendering height.
|
<T extends InputDevice> |
getInputDevice(Class<T> type)
Get the input device instance from its type.
|
Sequencable |
getNextSequence()
Get the next sequence depending of the
Sequencable.end() or Sequencable.end(Class, Object...) call. |
protected int |
getWidth()
Get the rendering width.
|
protected int |
getX()
Get main frame location x.
|
protected int |
getY()
Get main frame location y.
|
abstract void |
load()
Loading sequence data.
|
void |
notifyClosed()
Called when screen has been closed.
|
void |
notifyFocusGained()
Called when gained focus.
|
void |
notifyFocusLost()
Called when lost focus.
|
protected void |
onLoaded(double extrp,
Graphic g)
Called when the sequence has been loaded.
|
protected void |
onResolutionChanged(int width,
int height,
int rate)
Called when the resolution changed.
|
void |
onTerminated(boolean hasNextSequence)
Called when sequence is closing.
|
void |
setExtrapolated(boolean extrapolated)
Set the extrapolation flag.
|
void |
setFilter(Filter filter)
Set the filter to use.
|
void |
setResolution(Resolution newSource)
Set the new resolution used by the sequence.
|
void |
setSystemCursorVisible(boolean visible)
Set the system cursor visibility.
|
void |
start(Screen screen)
Start sequence.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
render
public Sequence(Context context, Resolution resolution)
context
- The context reference.resolution
- The resolution source reference.public abstract void load()
public final void setFilter(Filter filter)
filter
- The filter to use (if null
then Filter.NO_FILTER
is used).protected final int getWidth()
protected final int getHeight()
protected final int getX()
protected final int getY()
protected void onLoaded(double extrp, Graphic g)
extrp
- The extrapolation value.g
- The graphic output.protected void onResolutionChanged(int width, int height, int rate)
width
- The new screen width.height
- The new screen height.rate
- The new rate.public void start(Screen screen)
Sequencable
start
in interface Sequencable
screen
- The screen used for the sequence.public final void end()
Sequencable
end
in interface Sequencable
public final void end(Class<? extends Sequencable> nextSequenceClass, Object... arguments)
Sequencable
end
in interface Sequencable
nextSequenceClass
- The next sequence class reference.arguments
- The sequence arguments list if needed by its constructor.public final void addKeyListener(InputDeviceKeyListener listener)
Sequencable
addKeyListener
in interface Sequencable
listener
- The listener to add.public final void setExtrapolated(boolean extrapolated)
Sequencable
setExtrapolated
in interface Sequencable
extrapolated
- true
will activate it, false
will disable it.public final void setResolution(Resolution newSource)
Sequencable
setResolution
in interface Sequencable
newSource
- The new resolution used.public final void setSystemCursorVisible(boolean visible)
Sequencable
setSystemCursorVisible
in interface Sequencable
visible
- true
if visible, false
else.public final Config getConfig()
Sequencable
getConfig
in interface Sequencable
public final int getFps()
Sequencable
getFps
in interface Sequencable
public final <T extends InputDevice> T getInputDevice(Class<T> type)
Sequencable
getInputDevice
in interface Sequencable
T
- The input device.type
- The input device type.public final Sequencable getNextSequence()
Sequencable
Sequencable.end()
or Sequencable.end(Class, Object...)
call.getNextSequence
in interface Sequencable
null
if none.public void onTerminated(boolean hasNextSequence)
Sequencable
onTerminated
in interface Sequencable
hasNextSequence
- true
if there is a next sequence, false
else (then application
will end definitely).public void notifyFocusGained()
ScreenListener
notifyFocusGained
in interface ScreenListener
public void notifyFocusLost()
ScreenListener
notifyFocusLost
in interface ScreenListener
public final void notifyClosed()
ScreenListener
notifyClosed
in interface ScreenListener
Copyright © 2016 Byron 3D Games Studio. All rights reserved.