private void BuildWithMapInfo(CCTMXMapInfo mapInfo) { m_tMapSize = mapInfo.MapSize; m_tTileSize = mapInfo.TileSize; m_nMapOrientation = mapInfo.Orientation; ObjectGroups = mapInfo.ObjectGroups; Properties = mapInfo.Properties; m_pTileProperties = mapInfo.TileProperties; int idx = 0; //Layers List<CCTMXLayerInfo> layers = mapInfo.Layers; if (layers != null && layers.Count > 0) { for (int i = 0; i < layers.Count; i++) { CCTMXLayerInfo layerInfo = layers[i]; if (layerInfo != null && layerInfo.Visible) { CCTMXLayer child = ParseLayer(layerInfo, mapInfo); AddChild(child, idx, idx); // update content size with the max size CCSize childSize = child.ContentSize; CCSize currentSize = ContentSize; currentSize.Width = Math.Max(currentSize.Width, childSize.Width); currentSize.Height = Math.Max(currentSize.Height, childSize.Height); ContentSize = currentSize; idx++; } } } }
private CCTMXLayer ParseLayer(CCTMXLayerInfo layerInfo, CCTMXMapInfo mapInfo) { CCTMXTilesetInfo tileset = tilesetForLayer(layerInfo, mapInfo); CCTMXLayer layer = new CCTMXLayer(tileset, layerInfo, mapInfo); // tell the layerinfo to release the ownership of the tiles map. layerInfo.OwnTiles = false; layer.SetupTiles(); return layer; }