示例#1
0
        void flipIt(float dt)
        {
            CCTileMapLayer layer = tileMap.LayerNamed("Layer 0");

            //blue diamond
            var tileCoord = new CCTileMapCoordinates(1, 10);

            CCTileGidAndFlags gidAndFlags = layer.TileGIDAndFlags(tileCoord);
            CCTileFlags       flags       = gidAndFlags.Flags;
            short             GID         = gidAndFlags.Gid;

            // Vertical
            if ((flags & CCTileFlags.Vertical) != 0)
            {
                flags &= ~CCTileFlags.Vertical;
            }
            else
            {
                flags |= CCTileFlags.Vertical;
            }


            layer.SetTileGID(new CCTileGidAndFlags(GID, flags), tileCoord);


            tileCoord   = new CCTileMapCoordinates(1, 8);
            gidAndFlags = layer.TileGIDAndFlags(tileCoord);
            GID         = gidAndFlags.Gid;
            flags       = gidAndFlags.Flags;

            // Vertical
            if ((flags & CCTileFlags.Vertical) != 0)
            {
                flags &= ~CCTileFlags.Vertical;
            }
            else
            {
                flags |= CCTileFlags.Vertical;
            }

            layer.SetTileGID(new CCTileGidAndFlags(GID, flags), tileCoord);

            tileCoord   = new CCTileMapCoordinates(2, 8);
            gidAndFlags = layer.TileGIDAndFlags(tileCoord);
            GID         = gidAndFlags.Gid;
            flags       = gidAndFlags.Flags;

            // Horizontal
            if ((flags & CCTileFlags.Horizontal) != 0)
            {
                flags &= ~CCTileFlags.Horizontal;
            }
            else
            {
                flags |= CCTileFlags.Horizontal;
            }

            layer.SetTileGID(new CCTileGidAndFlags(GID, flags), tileCoord);
        }
示例#2
0
        void HandleCustomTilePropertyAt(int worldX, int worldY, CCTileMapLayer layer)
        {
            CCTileMapCoordinates tileAtXy = layer.ClosestTileCoordAtNodePosition(new CCPoint(worldX, worldY));

            CCTileGidAndFlags info = layer.TileGIDAndFlags(tileAtXy.Column, tileAtXy.Row);

            if (info != null)
            {
                Dictionary <string, string> properties = null;

                try
                {
                    properties = _map.TilePropertiesForGID(info.Gid);
                }
                catch
                {
                    // CocosSharp
                }

                if (properties != null && properties.ContainsKey("IsTreasure") && properties["IsTreasure"] == "true")
                {
                    layer.RemoveTile(tileAtXy);

                    // todo: Create a treasure chest entity
                }
            }
        }
示例#3
0
        public TMXReadWriteTest() : base("TileMaps/orthogonal-test2")
        {
            m_gid = CCTileGidAndFlags.EmptyTile;

            CCTileMapLayer layer = tileMap.LayerNamed("Layer 0");

            layer.Antialiased = true;

            tileMap.Scale = (1);

            CCSprite tile0 = layer.ExtractTile(1, 63);
            CCSprite tile1 = layer.ExtractTile(2, 63);
            CCSprite tile2 = layer.ExtractTile(3, 62); //new CCPoint(1,62));
            CCSprite tile3 = layer.ExtractTile(2, 62);

            tile0.AnchorPoint = (new CCPoint(0.5f, 0.5f));
            tile1.AnchorPoint = (new CCPoint(0.5f, 0.5f));
            tile2.AnchorPoint = (new CCPoint(0.5f, 0.5f));
            tile3.AnchorPoint = (new CCPoint(0.5f, 0.5f));

            CCMoveBy    move      = new CCMoveBy(0.5f, new CCPoint(0, 160));
            CCRotateBy  rotate    = new CCRotateBy(2, 360);
            CCScaleBy   scale     = new CCScaleBy(2, 5);
            CCFadeOut   opacity   = new CCFadeOut(2);
            CCFadeIn    fadein    = new CCFadeIn(2);
            CCScaleTo   scaleback = new CCScaleTo(1, 1);
            CCCallFuncN finish    = new CCCallFuncN(removeSprite);
            CCSequence  sequence  = new CCSequence(move, rotate, scale, opacity, fadein, scaleback, finish);

            tile0.RunAction(sequence);
            tile1.RunAction(sequence);
            tile2.RunAction(sequence);
            tile3.RunAction(sequence);


            m_gid = layer.TileGIDAndFlags(0, 63);

            Schedule(updateCol, 2.0f);
            Schedule(repaintWithGID, 2.0f);
            Schedule(removeTiles, 1.0f);


            m_gid2 = CCTileGidAndFlags.EmptyTile;
        }