// private private CCTMXLayer parseLayer(CCTMXLayerInfo layerInfo, CCTMXMapInfo mapInfo) { CCTMXTilesetInfo tileset = tilesetForLayer(layerInfo, mapInfo); CCTMXLayer layer = CCTMXLayer.layer(tileset, layerInfo, mapInfo); // tell the layerinfo to release the ownership of the tiles map. layerInfo.ownTiles = false; layer.setupTiles(); return layer; }
/** initializes a TMX Tiled Map with a TMX file */ protected CCTMXTiledMap(String tmxFile) { super(); if (tmxFile == null) { ccMacros.CCLOG(LOG_TAG, "TMXTiledMap: tmx file should not bi nil"); return; } setContentSize(CGSize.zero()); CCTMXMapInfo mapInfo = CCTMXMapInfo.formatWithTMXFile(tmxFile); assert (mapInfo.tilesets.size() != 0) : "TMXTiledMap: Map not found. Please check the filename."; mapSize_ = mapInfo.mapSize; tileSize_ = mapInfo.tileSize; mapOrientation_ = mapInfo.orientation; objectGroups = mapInfo.objectGroups; properties_ = mapInfo.properties; tileProperties_ = mapInfo.tileProperties; int idx = 0; for (CCTMXLayerInfo layerInfo : mapInfo.layers) { if (layerInfo.visible) { CCTMXLayer child = parseLayer(layerInfo, mapInfo); addChild(child, idx, idx); // update content size with the max size CGSize childSize = child.getContentSize(); CGSize currentSize = getContentSize(); currentSize.width = (currentSize.width > childSize.width ? currentSize.width : childSize.width); currentSize.height = (currentSize.height > childSize.height ? currentSize.height : childSize.height); setContentSize(currentSize); idx++; } } }