Package org.openpatch.scratch.internal
Class StageAccess
java.lang.Object
org.openpatch.scratch.internal.StageAccess
How an extension package reaches something on
Stage that is not part
of its public face.
TiledMap has to put a map's tiles into the stage's stamp queues, and
it lives in its own package. Without this, the queue-taking stamp method would
have to be public on Stage, where it would sit in every learner's
autocomplete while taking a type - Stamp - that they have no way to
build. The same trick as StageHooks, in the other direction: that one
lets the render loop into a stage, this one lets an extension in.
Stage installs an implementation when the class is loaded, which has
always happened by the time anything can call get() - reaching it
requires a stage to pass in.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StageAccessget()Returns the installed accessor.static voidinstall(StageAccess access) Installs the implementation.abstract voidStamps images permanently onto one of a stage's layers.
-
Constructor Details
-
StageAccess
public StageAccess()
-
-
Method Details
-
install
Installs the implementation. Called byStage; the first one wins, so this cannot be swapped out from outside the library.- Parameters:
access- the implementation to install
-
get
Returns the installed accessor.- Returns:
- the accessor
- Throws:
IllegalStateException- if no stage has been loaded, which should be impossible from anywhere that has a stage to hand
-
stamp
Stamps images permanently onto one of a stage's layers.- Parameters:
stage- the stage to stamp ontostamps- the images to stamplayer- which layer to stamp them onto
-