Interface ExtensionContext
public interface ExtensionContext
What an extension may hook into. Each method says
which thread its hook runs on. An exception thrown by a hook is printed once, naming the
extension, and the hook is switched off; the game goes on.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final recordDecoded pixels from an image format of an extension's.static interfaceA drawn frame at stage size; its pixels are read back only when asked for.static interfaceTurns the bytes of an image file into pixels; runs on loading threads.static final classA slot in the input snapshot: polled on the window thread, copied to the game thread with each batch of ticks, so no locking is needed.static interfaceThe window thread's side of the input snapshot, filled byonInputPoll(Consumer).static final recordA key went down or up (auto-repeat never arrives).static interfaceDraws into a layer of a stage.static final recordAn exception from learner code, with the learner's frame (null if there is none).static final recordSomething the mouse did, in stage coordinates. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddLayerDrawer(Layer layer, ExtensionContext.LayerDrawer drawer) Draws into a layer every frame, after the layer's canvas and before its sprites: map tiles, drawings.voidDraws above everything (UI, texts and monitors included) in stage coordinates; captures leave it out (Studio's watch pins).voidAfter a frame was drawn, on the window thread.voidbeforeTick(Consumer<Stage> hook) Every tick, after the tick's input and before timers andrun().<T> voidCalls a listener interface on the stage and every sprite of it that implements it, at the point of the tick where key events arrive.long<T> Tinput(ExtensionContext.InputKey<T> key) This batch's copy of a slot of the input snapshot.booleanvoidAt the end of the program, afterwhenExits().voidOnce per batch of ticks, on the window thread (the one that started GLFW): poll devices into the snapshot.voidEvery key press and release, before learner code sees it; observe only.voidA learner exception stopped the game.voidEvery mouse event, before learner code sees it; observe only.voidonStageCreated(Consumer<Stage> hook) A stage was made (on the thread that made it, usually the game thread or main).voidonStageDisposed(Consumer<Stage> hook) A stage stopped being shown.voidregisterImageFormat(String suffix, ExtensionContext.ImageDecoder decoder) Images whose name ends insuffix(e.g.voidrunOnGameThread(Runnable task) Runs a task at the start of the next tick, before input.
-
Method Details
-
onStageCreated
-
onStageDisposed
-
beforeTick
-
onKey
Every key press and release, before learner code sees it; observe only. Game thread. -
onMouse
Every mouse event, before learner code sees it; observe only. Game thread. -
onExit
At the end of the program, afterwhenExits(). Game thread. -
onLearnerError
A learner exception stopped the game. Game thread. -
addLayerDrawer
Draws into a layer every frame, after the layer's canvas and before its sprites: map tiles, drawings. Game thread, when the draw list is made. -
addOverlayDrawer
Draws above everything (UI, texts and monitors included) in stage coordinates; captures leave it out (Studio's watch pins). Game thread. -
dispatch
Calls a listener interface on the stage and every sprite of it that implements it, at the point of the tick where key events arrive. Learner exceptions thrown there stop the game like any learner exception. Game thread.- Type Parameters:
T- the listener interface
-
input
This batch's copy of a slot of the input snapshot. Game thread. -
getTickCount
long getTickCount()- Returns:
- ticks run so far
-
isLoading
boolean isLoading()- Returns:
- whether the loading screen is up
-
onInputPoll
Once per batch of ticks, on the window thread (the one that started GLFW): poll devices into the snapshot. GLFW polling functions only; setting GLFW callbacks is not allowed. -
afterFrame
After a frame was drawn, on the window thread. -
runOnGameThread
Runs a task at the start of the next tick, before input. -
registerImageFormat
Images whose name ends insuffix(e.g.".ase") are decoded bydecoder.
-