Class GameWorld
java.lang.Object
com.codename1.gaming.level.GameWorld
A large game space made of linked
Regions, streamed in and out around the player so the
world can exceed memory while transitions stay seamless. Hold the regions directly (small
worlds) or supply a RegionProvider to page them by id. Call #update(double,double) each
frame with the player's world position: the world keeps the containing region active, loads
its linked neighbours, and unloads (saving) regions beyond #getKeepRadius() links away.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic GameWorldintHow many neighbour links away from the active region stay resident.Returns a resident region, paging it in through the provider if needed.Currently-resident regions.setKeepRadius(int keepRadius) setProvider(RegionProvider provider) toJson()Serializes the resident regions + active region as a JSON object.voidupdate(double playerWorldX, double playerWorldZ) Drives streaming: picks the region containing the player (preferring a neighbour of the current active region for seamless crossings), loads neighbours within#getKeepRadius()and unloads (persisting) the rest.
-
Constructor Details
-
GameWorld
public GameWorld() -
GameWorld
-
-
Method Details
-
getProvider
-
setProvider
-
getKeepRadius
public int getKeepRadius()How many neighbour links away from the active region stay resident. -
setKeepRadius
-
toJson
Serializes the resident regions + active region as a JSON object. (A provider-backed world persists individual regions through itsRegionProvider; this inline form suits small/medium worlds embedded in a level file.) -
fromMap
-
addRegion
-
getRegion
-
getActiveRegion
-
setActiveRegion
-
residentRegions
-
update
public void update(double playerWorldX, double playerWorldZ) Drives streaming: picks the region containing the player (preferring a neighbour of the current active region for seamless crossings), loads neighbours within#getKeepRadius()and unloads (persisting) the rest.
-