Class Scene
java.lang.Object
com.codename1.gaming.Scene
A z-ordered collection of sprites with an optional camera offset.
A Scene is the model a SpriteRenderer draws: it holds the sprites, keeps
them sorted by Sprite#getZOrder() (higher draws on top, re-sorted only when
the contents change) and applies a camera offset that scrolls the whole scene.
#update(double) advances every sprite (driving AnimatedSprite playback).
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a sprite to the scene.voidclear()Removes all sprites.get(int index) intintvoidForces a re-sort on the next frame.voidRemoves a sprite from the scene.voidsetCamera(int x, int y) Sets the camera offset subtracted from sprite positions while rendering.intsize()voidupdate(double deltaSeconds) Advances every sprite in the scene by callingSprite#onUpdate(double).
-
Constructor Details
-
Scene
public Scene()
-
-
Method Details
-
add
Adds a sprite to the scene. -
remove
Removes a sprite from the scene. -
clear
public void clear()Removes all sprites. -
size
public int size() -
get
-
update
public void update(double deltaSeconds) Advances every sprite in the scene by callingSprite#onUpdate(double). Iterating by index tolerates a sprite removing itself during update. -
markSortDirty
public void markSortDirty()Forces a re-sort on the next frame. Call this after changing a sprite's z-order so the new ordering takes effect. -
getCameraX
public int getCameraX() -
getCameraY
public int getCameraY() -
setCamera
public void setCamera(int x, int y) Sets the camera offset subtracted from sprite positions while rendering.
-