Class MapObjects

java.lang.Object
com.badlogic.gdx.maps.MapObjects
All Implemented Interfaces:
Iterable<MapObject>

public class MapObjects extends Object implements Iterable<MapObject>
  • Constructor Details

    • MapObjects

      public MapObjects()
      Creates an empty set of MapObject instances
  • Method Details

    • get

      public MapObject get(int index)
      Parameters:
      index -
      Returns:
      the MapObject at the specified index
    • get

      public MapObject get(String name)
      Parameters:
      name -
      Returns:
      the first object having the specified name, if one exists, otherwise null
    • getIndex

      public int getIndex(String name)
      Get the index of the object having the specified name, or -1 if no such object exists.
    • getIndex

      public int getIndex(MapObject object)
      Get the index of the object in the collection, or -1 if no such object exists.
    • getCount

      public int getCount()
      Returns:
      number of objects in the collection
    • add

      public void add(MapObject object)
      Parameters:
      object - instance to be added to the collection
    • remove

      public void remove(int index)
      Parameters:
      index - removes MapObject instance at index
    • remove

      public void remove(MapObject object)
      Parameters:
      object - instance to be removed
    • getByType

      public <T extends MapObject> Array<T> getByType(Class<T> type)
      Parameters:
      type - class of the objects we want to retrieve
      Returns:
      array filled with all the objects in the collection matching type
    • getByType

      public <T extends MapObject> Array<T> getByType(Class<T> type, Array<T> fill)
      Parameters:
      type - class of the objects we want to retrieve
      fill - collection to put the returned objects in
      Returns:
      array filled with all the objects in the collection matching type
    • iterator

      public Iterator<MapObject> iterator()
      Specified by:
      iterator in interface Iterable<MapObject>
      Returns:
      iterator for the objects within the collection