Skip to content

Commit

Permalink
ObjectMaker FromTiledMap support now multipe tileSets
Browse files Browse the repository at this point in the history
  • Loading branch information
alamboley committed Nov 27, 2012
1 parent 3c64015 commit 5abd134
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/com/citrusengine/utils/ObjectMaker2D.as
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,10 @@
*
* <p>For the objects, you can add their name and don't forget their types : package name + class name.
* It also supports properties.</p>
* @param levelXML the TMX provided by the Tiled Map Editor software, convert it into an xml before.
* @param images an array of bitmap used by tileSets. The name of the bitmap must correspond to the tileSet image source name.
*/
public static function FromTiledMap(levelXML:XML, TilesImg:Class, addToCurrentState:Boolean = true):Array {
public static function FromTiledMap(levelXML:XML, images:Array, addToCurrentState:Boolean = true):Array {

var ce:CitrusEngine = CitrusEngine.getInstance();
var params:Object;
Expand Down Expand Up @@ -151,8 +153,16 @@
bmpData.lock();

for each (var tileSet:TmxTileSet in tmx.tileSets) {
//TODO : support multiple tiles img.
bmp = new TilesImg();

for each (var image:Bitmap in images) {

if (tileSet.imageSource == image.name) {
bmp = image;
break;

} else throw new Error("ObjectMaker didn't find an image name corresponding to the tileset imagesource name, add its name to your bitmap.");
}

tileSet.image = bmp.bitmapData;

for (var i:uint = 0; i < mapTilesX; ++i) {
Expand All @@ -165,8 +175,6 @@

if (mapTiles[i][j] <= tileSet.numCols) {

//TODO : support spacing
//rectangleSelection.x = mapTiles[i][j] * (tmx.tileWidth + tileSet.spacing) - tmx.tileWidth;
rectangleSelection.x = mapTiles[i][j] * tmx.tileWidth - tmx.tileWidth;
rectangleSelection.y = 0;

Expand Down

0 comments on commit 5abd134

Please sign in to comment.