/** @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> getByType (Class<T> type) { return getByType(type, new Array<T>()); }
@Override public MapObjects getObjects() { if (objects == null) { objects = new MapObjects(); } return objects; }
if (group.getObjects().getCount() == 1) { PolylineMapObject o = (PolylineMapObject)group.getObjects().get(0); if (group.getObjects().getCount() > 1) { throw new GdxRuntimeException("Too many routes"); } else if (group.getObjects().getCount() == 0) { throw new GdxRuntimeException("No route defined for this track");
MapObjects mapObjects = layer.getObjects(); mapObjects.add(new CircleMapObject(280, 400, 50)); loadingStatus += "- MapObject : " + mapObjects.getByType(MapObject.class).size + "\n"; loadingStatus += "- CircleMapObject : " + mapObjects.getByType(CircleMapObject.class).size + "\n"; loadingStatus += "- EllipseMapObject : " + mapObjects.getByType(EllipseMapObject.class).size + "\n"; loadingStatus += "- PolygonMapObject : " + mapObjects.getByType(PolygonMapObject.class).size + "\n"; loadingStatus += "- PolylineMapObject : " + mapObjects.getByType(PolylineMapObject.class).size + "\n"; loadingStatus += "- RectangleMapObject : " + mapObjects.getByType(RectangleMapObject.class).size + "\n"; loadingStatus += "- TextureMapObject : " + mapObjects.getByType(TextureMapObject.class).size + "\n"; loadingStatus += "- TiledMapTileMapObject : " + mapObjects.getByType(TiledMapTileMapObject.class).size + "\n";
loadProperties(object.getProperties(), properties); objects.add(object);
MapLayer group = mapUtils.getObjectGroup(ObjectGroup.Trees); if (group.getObjects().getCount() > 0) { models = new ArrayList<TreeStillModel>(group.getObjects().getCount()); for (int i = 0; i < group.getObjects().getCount(); i++) { RectangleMapObject o = (RectangleMapObject)group.getObjects().get(i);
loadProperties(object.getProperties(), properties); objects.add(object);
/** @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> getByType (Class<T> type) { return getByType(type, new Array<T>()); }
loadProperties(object.getProperties(), properties); layer.getObjects().add(object);
@Override public MapObjects getObjects() { if (objects == null) { objects = new MapObjects(); } return objects; }
int objectLayerId = 5; TiledMapTileLayer collisionObjectLayer = (TiledMapTileLayer)map.getLayers().get(objectLayerId); MapObjects objects = collisionObjectLayer.getObjects(); // there are several other types, Rectangle is probably the most common one for (RectangleMapObject rectangleObject : objects.getByType(RectangleMapObject.class)) { Rectangle rectangle = rectangleObject.getRectangle(); if (Intersector.overlaps(rectangle, player.getRectangle()) { // collision happened } }
loadProperties(object.getProperties(), properties); objects.add(object);
@Override public MapObjects getObjects() { if (objects == null) { objects = new MapObjects(); } return objects; }
/** @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> getByType (Class<T> type) { return getByType(type, new Array<T>()); }