コード例 #1
0
ファイル: CCTMXTiledMap.cs プロジェクト: ununian/CocosSharp
        // 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++;
                    }
                }
            }
        }
コード例 #2
0
ファイル: CCTMXTiledMap.cs プロジェクト: ununian/CocosSharp
        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);
        }
コード例 #3
0
        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();
        }
コード例 #4
0
ファイル: CCTMXTiledMap.cs プロジェクト: KerwinMa/CocosSharp
        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;
        }
コード例 #5
0
ファイル: IntroLayer.cs プロジェクト: netonjm/CSExtensionKit
 public IntroLayer()
 {
     tileMap = new CCTMXTiledMap("TileMap.tmx");
     background = tileMap.LayerNamed("Background");
     AddChild(background);
 }