Beispiel #1
0
        // Methods solely used for construction

        void BuildWithMapInfo(CCTMXMapInfo mapInfo)
        {
            MapInfo        = mapInfo;
            MapSize        = mapInfo.MapSize;
            TileSize       = mapInfo.TileSize;
            MapOrientation = mapInfo.Orientation;
            ObjectGroups   = mapInfo.ObjectGroups;
            Properties     = mapInfo.Properties;
            TileProperties = mapInfo.TileProperties;

            int idx = 0;

            List <CCTMXLayerInfo> layers = mapInfo.Layers;

            if (layers != null && layers.Count > 0)
            {
                foreach (CCTMXLayerInfo layerInfo in layers)
                {
                    if (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++;
                    }
                }
            }
        }
Beispiel #2
0
        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);
        }
        private void InitializeTileMap()
        {
            _tileMap = new CCTMXTiledMap("TileMap.tmx");
            _background = _tileMap.LayerNamed("Background");
            _foreground = _tileMap.LayerNamed("Foreground");

            _meta = _tileMap.LayerNamed("Meta");

            AddChild(_tileMap, -5);

            CCTMXObjectGroup objectGroup = _tileMap.ObjectGroupNamed("Objects");
            if (objectGroup == null)
            {
                CCLog("tile map has no objects object layer");
            }

            var spawnPoint = objectGroup.ObjectNamed("SpawnPoint");

            int x = int.Parse(spawnPoint["x"]);//.intValue();
            int y = int.Parse(spawnPoint["y"]); //spawnPoint->valueForKey("y")).intValue();
        }
Beispiel #4
0
        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;
        }
Beispiel #5
0
 public IntroLayer()
 {
     tileMap = new CCTMXTiledMap("TileMap.tmx");
     background = tileMap.LayerNamed("Background");
     AddChild(background);
 }