public class OrthoCachedTiledMapRenderer extends Object implements TiledMapRenderer, Disposable
setOverCache(float)
. When the
view reaches the edge of the cached tiles, the cache is rebuilt at the new view position.
This class may have poor performance when tiles are often changed dynamically, since the cache must be rebuilt after each change.
Constructor and Description |
---|
OrthoCachedTiledMapRenderer(TiledMap map)
Creates a renderer with a unit scale of 1 and cache size of 2000.
|
OrthoCachedTiledMapRenderer(TiledMap map,
float unitScale)
Creates a renderer with a cache size of 2000.
|
OrthoCachedTiledMapRenderer(TiledMap map,
float unitScale,
int cacheSize) |
Modifier and Type | Method and Description |
---|---|
void |
dispose()
Releases all resources of this object.
|
SpriteCache |
getSpriteCache() |
void |
invalidateCache()
Causes the cache to be rebuilt the next time it is rendered.
|
boolean |
isCached()
Returns true if tiles are currently cached.
|
void |
render()
Renders all the layers of a map.
|
void |
render(int[] layers)
Renders the given layers of a map.
|
void |
renderObject(MapObject object) |
void |
renderObjects(MapLayer layer) |
void |
renderTileLayer(TiledMapTileLayer layer) |
void |
setBlending(boolean blending) |
void |
setMaxTileSize(float maxPixelWidth,
float maxPixelHeight)
Expands the view size in each direction, ensuring that tiles of this size or smaller are never culled from the visible
portion of the view.
|
void |
setOverCache(float overCache)
Sets the percentage of the view that is cached in each direction.
|
void |
setView(Matrix4 projection,
float x,
float y,
float width,
float height)
Sets the projection matrix for rendering, as well as the bounds of the map which should be rendered.
|
void |
setView(OrthographicCamera camera)
Sets the projection matrix and viewbounds from the given camera.
|
public OrthoCachedTiledMapRenderer(TiledMap map)
public OrthoCachedTiledMapRenderer(TiledMap map, float unitScale)
public OrthoCachedTiledMapRenderer(TiledMap map, float unitScale, int cacheSize)
cacheSize
- The maximum number of tiles that can be cached.public void setView(OrthographicCamera camera)
MapRenderer
setView
in interface MapRenderer
camera
- the OrthographicCamera
public void setView(Matrix4 projection, float x, float y, float width, float height)
MapRenderer
setView
in interface MapRenderer
public void render()
MapRenderer
render
in interface MapRenderer
public void render(int[] layers)
MapRenderer
render
in interface MapRenderer
layers
- the layers to render.public void renderObjects(MapLayer layer)
renderObjects
in interface TiledMapRenderer
public void renderObject(MapObject object)
renderObject
in interface TiledMapRenderer
public void renderTileLayer(TiledMapTileLayer layer)
renderTileLayer
in interface TiledMapRenderer
public void invalidateCache()
public boolean isCached()
public void setOverCache(float overCache)
Eg, 0.75 will cache 75% of the width of the view to the left and right of the view, and 75% of the height of the view above and below the view.
public void setMaxTileSize(float maxPixelWidth, float maxPixelHeight)
The amount of tiles cached is computed using (view size + max tile size) * overCache
, meaning the max tile size
increases the amount cached and possibly setOverCache(float)
can be reduced.
If the view size and setOverCache(float)
are configured so the size of the cached tiles is always larger than the
largest tile size, this setting is not needed.
public void setBlending(boolean blending)
public SpriteCache getSpriteCache()
public void dispose()
Disposable
dispose
in interface Disposable
Copyright © 2014. All rights reserved.