Package playn.core
Class Platform
java.lang.Object
playn.core.Platform
- Direct Known Subclasses:
StubPlatform
Provides access to all PlayN cross-platform services.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
static enum
Defines the lifecycle events.static enum
Enumerates the supported platform types. -
Field Summary
FieldsModifier and TypeFieldDescriptionAny errors reported viareportError(java.lang.String, java.lang.Throwable)
will be emitted to this signal in addition to being logged.This signal will be emitted at the start of every frame after the platform is started.A signal emitted with lifecycle events. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract Assets
assets()
Returns theAssets
service.abstract Audio
audio()
Returns theAudio
service.<E> void
dispatchEvent
(Signal<E> signal, E event) Dispatchesevent
onsignal
and catches any error that propagates out of the event dispatch, reporting it viareportError(java.lang.String, java.lang.Throwable)
.abstract Exec
exec()
Returns theExec
service.abstract Graphics
graphics()
Returns theGraphics
service.abstract Input
input()
Returns theInput
service.void
invokeAsync
(Runnable action) Deprecated.void
invokeLater
(Runnable runnable) Deprecated.boolean
Deprecated.abstract Json
json()
Returns theJson
service.abstract Log
log()
Returns theLog
service.abstract Net
net()
Returns theNet
service.abstract void
Opens the given URL in the default browser.void
reportError
(String message, Throwable cause) Called when a backend (or other framework code) encounters an exception that it can recover from, but which it would like to report in some orderly fashion.abstract Storage
storage()
Returns theStorage
storage service.abstract int
tick()
Returns the number of milliseconds that have elapsed since the game started.abstract double
time()
Returns the current time, as a double value in millis since January 1, 1970, 00:00:00 GMT.abstract Platform.Type
type()
Returns the platformPlatform.Type
.
-
Field Details
-
lifecycle
A signal emitted with lifecycle events. -
frame
This signal will be emitted at the start of every frame after the platform is started. Games should connect to it to drive their main loop. -
errors
Any errors reported viareportError(java.lang.String, java.lang.Throwable)
will be emitted to this signal in addition to being logged. Games can connect to this signal if they wish to capture and record platform errors.
-
-
Constructor Details
-
Platform
public Platform()
-
-
Method Details
-
type
Returns the platformPlatform.Type
. -
time
public abstract double time()Returns the current time, as a double value in millis since January 1, 1970, 00:00:00 GMT. This is equivalent to the standard JREnew Date().getTime();
, but is terser and avoids the use oflong
, which is best avoided when translating to JavaScript. -
tick
public abstract int tick()Returns the number of milliseconds that have elapsed since the game started. -
openURL
Opens the given URL in the default browser. -
assets
Returns theAssets
service. -
audio
Returns theAudio
service. -
exec
Returns theExec
service. -
graphics
Returns theGraphics
service. -
input
Returns theInput
service. -
json
Returns theJson
service. -
log
Returns theLog
service. -
net
Returns theNet
service. -
storage
Returns theStorage
storage service. -
reportError
Called when a backend (or other framework code) encounters an exception that it can recover from, but which it would like to report in some orderly fashion. NOTE: this method may be called from threads other than the main PlayN thread. -
dispatchEvent
Dispatchesevent
onsignal
and catches any error that propagates out of the event dispatch, reporting it viareportError(java.lang.String, java.lang.Throwable)
. -
invokeLater
Deprecated. -
isAsyncSupported
Deprecated. -
invokeAsync
Deprecated.
-
Exec.invokeAsync(java.lang.Runnable)
.