atomicptr / openfl-tiled

openfl-tiled is a library which gives OpenFL developers the ability to use the TILED map editor.
Other
45 stars 21 forks source link

Tilemap.hx [enhancement] pull multiple objects #65

Open smoketh opened 10 years ago

smoketh commented 10 years ago

Please consider adding this function to Tilemap.hx

/**
  * Returns all objects with matching name in a given object group
  * @param name The name of the object
  * @param inObjectGroup The object group which contains this object.
  * @return An TiledObject, null if there is no such object.
  */
public function getObjectsByName(name:String, inObjectGroup:TiledObjectGroup):Array<TiledObject>
{
    var k:Array<TiledObject> = new Array<TiledObject>();
    for(object in inObjectGroup) {
        if(object.name == name) {
            k.push(object);
        }
    }
    return k;
}

and subsequently changing getObjectByName comment to

     /**
      * Returns first object with matching name in a given object group
      * @param name The name of the object
      * @param inObjectGroup The object group which contains this object.
      * @return An TiledObject, null if there is no such object.
      */

Reasoning behind is pretty simple - a lot of times i use standardized objects within given map and just copy-paste them. Changing name for every single one of them would be stupid, to say the least.

atomicptr commented 10 years ago

Since I'm not working with openfl-tiled atm, I'm not really working on it. If it's important for you I'd recommend to make a pull request.

Sorry for the inconvenience.