|
PulpCore | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object pulpcore.Stage
public class Stage
The Stage class manages Scenes and drawing to the Surface. The Stage class is a singleton that Scenes can access using its static methods.
Stage runs the animation loop. The main class (e.g. CoreApplet) creates, starts, and stops the Stage.
Field Summary | |
---|---|
static int |
AUTO_CENTER
Automatically center the Scene in the Stage. |
static int |
AUTO_FIT
Automatically scale the Scene to the Stage dimensions, preserving the Scene's aspect ratio. |
static int |
AUTO_OFF
Perform no auto scaling (default) |
static int |
AUTO_STRETCH
Automatically stretch the Scene to the Stage dimensions. |
static int |
DEFAULT_FPS
60 fps, or the screen's refresh rate if it is between 55hz and 65hz. |
static int |
HIGH_FPS
60 fps |
static int |
LOW_FPS
15 fps |
static int |
MAX_FPS
No limit to the frame rate (not recommended) |
static int |
MEDIUM_FPS
30 fps |
Constructor Summary | |
---|---|
Stage(pulpcore.platform.Surface surface,
pulpcore.platform.AppContext appContext)
|
Method Summary | |
---|---|
static boolean |
canPopScene()
Returns true if the there are Scenes on the scene stack. |
void |
destroy()
|
static double |
getActualFrameRate()
Gets the actual frame rate the Stage is displaying in frames per second. |
static Transform |
getDefaultTransform()
|
static int |
getFrameRate()
Gets the current desired frame rate in frames per second. |
static int |
getHeight()
|
static Sprite |
getInfoOverlay()
|
static Scene |
getScene()
Gets the current active Scene. |
static CoreImage |
getScreenshot()
Gets a screenshot of the current appearance of the stage. |
static void |
getScreenshot(CoreImage image,
int x,
int y)
Gets a screenshot at the specified location on the screen and copies it to the specified image. |
static int |
getWidth()
|
static void |
invokeOnShutdown(Runnable runnable)
Sets the runnable to execute at application shutdown. |
static boolean |
isAnimationThread()
Returns true if the current thread is the animation thread. |
void |
pollInput()
|
static void |
popScene()
Sets the current scene to the scene at the top of the scene stack. |
static void |
pushScene(Scene scene)
Pushes the current scene onto the scene stack and sets the current scene. |
static void |
replaceScene(Scene scene)
Unloads the current scene and sets the next scene to display. |
void |
run()
|
static void |
setAutoScale(int naturalWidth,
int naturalHeight)
|
static void |
setAutoScale(int naturalWidth,
int naturalHeight,
int autoScaleType)
|
static void |
setDirtyRectangles(Rect[] dirtyRectangles)
|
static void |
setDirtyRectangles(Rect[] dirtyRectangles,
int numDirtyRectangles)
|
static void |
setFrameRate(int desiredFPS)
Sets the desired frame rate in frames per second. |
static void |
setScene(Scene scene)
Unloads the current scene, empties the scene stack, and sets the next scene to display. |
static void |
setUncaughtExceptionScene(Scene scene)
Sets the scene to use when an uncaught exception occurs. |
void |
start()
|
void |
stop()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int MAX_FPS
public static final int HIGH_FPS
public static final int MEDIUM_FPS
public static final int LOW_FPS
public static final int DEFAULT_FPS
public static final int AUTO_OFF
public static final int AUTO_CENTER
public static final int AUTO_STRETCH
public static final int AUTO_FIT
Constructor Detail |
---|
public Stage(pulpcore.platform.Surface surface, pulpcore.platform.AppContext appContext)
Method Detail |
---|
public static int getWidth()
public static int getHeight()
public static Transform getDefaultTransform()
public static void setAutoScale(int naturalWidth, int naturalHeight)
public static void setAutoScale(int naturalWidth, int naturalHeight, int autoScaleType)
public static void setFrameRate(int desiredFPS)
To run at the highest frame rate possible (no pauses between frames),
invoke setFrameRate(Stage.MAX_FPS)
. Note, however,
running at the highest frame rate possible usually means
as many processor cycles are used as possible.
getFrameRate()
,
getActualFrameRate()
public static int getFrameRate()
setFrameRate(int)
.
setFrameRate(int)
,
getActualFrameRate()
public static double getActualFrameRate()
setFrameRate(int)
,
getFrameRate()
public static void setDirtyRectangles(Rect[] dirtyRectangles)
public static void setDirtyRectangles(Rect[] dirtyRectangles, int numDirtyRectangles)
public static Scene getScene()
public static boolean canPopScene()
public static void setScene(Scene scene)
Any scenes on the scene stack are unloaded and the scene stack is emptied.
The new scene isn't activated until the next frame. Multiple calls to the
setScene(Scene)
, replaceScene(Scene)
, pushScene(Scene)
,
and popScene()
methods within a single frame will cause the
first calls to be ignored - only the last call during
a single frame is recognized.
public static void replaceScene(Scene scene)
The scene stack is left untouched.
The new scene isn't activated until the next frame. Multiple calls to the
setScene(Scene)
, replaceScene(Scene)
, pushScene(Scene)
,
and popScene()
methods within a single frame will cause the
first calls to be ignored - only the last call during
a single frame is recognized.
public static void pushScene(Scene scene)
popScene()
is invoked.
The new scene isn't activated until the next frame. Multiple calls to the
setScene(Scene)
, replaceScene(Scene)
, pushScene(Scene)
,
and popScene()
methods within a single frame will cause the
first calls to be ignored - only the last call during
a single frame is recognized.
public static void popScene()
The popped scene isn't activated until the next frame. Multiple calls to the
setScene(Scene)
, replaceScene(Scene)
, pushScene(Scene)
,
and popScene()
methods within a single frame will cause the
first calls to be ignored - only the last call during
a single frame is recognized.
public static void setUncaughtExceptionScene(Scene scene)
When an uncaught exception occurs, the talkback field "pulpcore.uncaught-exception" is set to the exception's stack trace.
If the uncaught exception scene itself throws an exception, the app is stopped.
public static void invokeOnShutdown(Runnable runnable)
Scene2D.unload()
method, but multi-scene apps that require shutdown code to be
run (for example, logging off from a server) can use this method for convenience.
The runnable
is executed in the animation thread after all scenes are
unloaded.
public static CoreImage getScreenshot()
public static void getScreenshot(CoreImage image, int x, int y)
public static boolean isAnimationThread()
public void start()
public void stop()
public void destroy()
public void run()
run
in interface Runnable
public void pollInput()
public static Sprite getInfoOverlay()
|
PulpCore | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |