* @param index
* @return layer at index
*/
- public MapLayer getLayer(int index) {
+ public MapLayer get(int index) {
return layers.get(index);
}
* @param name
* @return first layer matching the name, null otherwise
*/
- public MapLayer getLayer(String name) {
+ public MapLayer get(String name) {
for (MapLayer layer : layers) {
if (name.equals(layer.getName())) {
return layer;
/**
* @param layer layer to be added to the set
*/
- public void addLayer(MapLayer layer) {
+ public void add(MapLayer layer) {
this.layers.add(layer);
}
/**
* @param index removes layer at index
*/
- public void removeLayer(int index) {
+ public void remove(int index) {
layers.removeIndex(index);
}
/**
* @param layer layer to be removed
*/
- public void removeLayer(MapLayer layer) {
+ public void remove(MapLayer layer) {
layers.removeValue(layer, true);
}
* @param type
* @return array with all the layers matching type
*/
- public <T extends MapLayer> Array<T> getLayersByType(Class<T> type) {
- return getLayersByType(type, new Array<T>());
+ public <T extends MapLayer> Array<T> getByType(Class<T> type) {
+ return getByType(type, new Array<T>());
}
/**
* @param fill array to be filled with the matching layers
* @return array with all the layers matching type
*/
- public <T extends MapLayer> Array<T> getLayersByType(Class<T> type, Array<T> fill) {
+ public <T extends MapLayer> Array<T> getByType(Class<T> type, Array<T> fill) {
fill.clear();
for (MapLayer layer : layers) {
if (type.isInstance(layer)) {
* Creates and empty set of MapObject instances
*/
public MapObjects() {
- objects = new Array<MapObject>();
+ objects = new Array<MapObject>();
}
/**
* @param index
* @return MapObject at index
*/
- public MapObject getObject(int index) {
+ public MapObject get(int index) {
return objects.get(index);
}
* @param name
* @return name matching object, null if it´s not in the set
*/
- public MapObject getObject(String name) {
+ public MapObject get(String name) {
for (MapObject object : objects) {
if (name.equals(object.getName())) {
return object;
/**
* @param object instance to be added to the collection
*/
- public void addObject(MapObject object) {
+ public void add(MapObject object) {
this.objects.add(object);
}
/**
* @param index removes MapObject instance at index
*/
- public void removeObject(int index) {
+ public void remove(int index) {
objects.removeIndex(index);
}
/**
* @param object instance to be removed
*/
- public void removeObject(MapObject object) {
+ public void remove(MapObject object) {
objects.removeValue(object, true);
}
/**
* @return number of objects in the collection
*/
- public int getNumObjects() {
+ public int getCount() {
return objects.size;
}
* @param type class of the objects we want to retrieve
* @return array filled with all the objects in the collection matching type
*/
- public <T extends MapObject> Array<T> getObjectsByType(Class<T> type) {
- return getObjectsByType(type, new Array<T>());
+ public <T extends MapObject> Array<T> getByType(Class<T> type) {
+ return getByType(type, new Array<T>());
}
/**
* @param fill collection to put the returned objects in
* @return array filled with all the objects in the collection matching type
*/
- public <T extends MapObject> Array<T> getObjectsByType(Class<T> type, Array<T> fill) {
+ public <T extends MapObject> Array<T> getByType(Class<T> type, Array<T> fill) {
fill.clear();
for (MapObject object : objects) {
if (type.isInstance(object)) {
}
}
}
- map.getLayers().addLayer(layer);
+ map.getLayers().add(layer);
}
}
if (properties != null) {
loadProperties(layer.getProperties(), properties);
}
- map.getLayers().addLayer(layer);
+ map.getLayers().add(layer);
}
}
loadObject(layer, objectElement);
}
- map.getLayers().addLayer(layer);
+ map.getLayers().add(layer);
}
}
if (properties != null) {
loadProperties(object.getProperties(), properties);
}
- layer.getObjects().addObject(object);
+ layer.getObjects().add(object);
}
}
public void render (int[] layers) {\r
spriteBatch.begin();\r
for (int layerIdx : layers) {\r
- MapLayer layer = map.getLayers().getLayer(layerIdx);\r
+ MapLayer layer = map.getLayers().get(layerIdx);\r
if (layer.isVisible()) {\r
if (layer instanceof TiledMapTileLayer) {\r
renderTileLayer((TiledMapTileLayer) layer);\r
layer.setCell(x, y, cell);
}
}
- layers.addLayer(layer);
+ layers.add(layer);
}
}
if(koala.velocity.y > 0) {\r
koala.position.y = tile.y - Koala.HEIGHT;\r
// we hit a block jumping upwards, let's destroy it!\r
- TiledMapTileLayer layer = (TiledMapTileLayer)map.getLayers().getLayer(1);\r
+ TiledMapTileLayer layer = (TiledMapTileLayer)map.getLayers().get(1);\r
layer.setCell((int)tile.x, (int)tile.y, null);\r
} else {\r
koala.position.y = tile.y + tile.height;\r
}\r
\r
private void getTiles(int startX, int startY, int endX, int endY, Array<Rectangle> tiles) {\r
- TiledMapTileLayer layer = (TiledMapTileLayer)map.getLayers().getLayer(1);\r
+ TiledMapTileLayer layer = (TiledMapTileLayer)map.getLayers().get(1);\r
rectPool.freeAll(tiles);\r
tiles.clear();\r
for(int y = startY; y <= endY; y++) {\r