示例#1
0
        public TMXIsoVertexZ()
        {
            CCTMXTiledMap map = CCTMXTiledMap.tiledMapWithTMXFile("TileMaps/iso-test-vertexz");

            addChild(map, 0, 1);

            CCSize s = map.contentSize;

            map.position = new CCPoint(-s.width / 2, 0);
            ////----UXLOG("ContentSize: %f, %f", s.width,s.height);

            // because I'm lazy, I'm reusing a tile as an sprite, but since this method uses vertexZ, you
            // can use any CCSprite and it will work OK.
            CCTMXLayer layer = map.layerNamed("Trees");

            m_tamara = layer.tileAt(new CCPoint(29, 29));

            CCActionInterval   move = CCMoveBy.actionWithDuration(10, new CCPoint(300 * 1 / CCDirector.sharedDirector().ContentScaleFactor, 250 * 1 / CCDirector.sharedDirector().ContentScaleFactor));
            CCActionInterval   back = (CCActionInterval)move.reverse();
            CCFiniteTimeAction seq  = CCSequence.actions(move, back);

            m_tamara.runAction(CCRepeatForever.actionWithAction((CCActionInterval)seq));

            schedule(repositionSprite);
        }
示例#2
0
        public TMXBug987()
        {
            CCTMXTiledMap map = CCTMXTiledMap.tiledMapWithTMXFile("TileMaps/orthogonal-test6");

            addChild(map, 0, 1);

            CCSize s1 = map.contentSize;

            CCLog.Log("ContentSize: %f, %f", s1.width, s1.height);

            List <CCNode> childs = map.children;
            CCTMXLayer    pNode;

            foreach (var item in childs)
            {
                pNode = (CCTMXLayer)item;
                if (pNode == null)
                {
                    break;
                }
                //pNode.Texture.setAntiAliasTexParameters();
            }

            map.anchorPoint = new CCPoint(0, 0);
            CCTMXLayer layer = map.layerNamed("Tile Layer 1");
            //layer.setTileGID(3, new CCPoint(2, 2));
        }
示例#3
0
        public TMXReadWriteTest()
        {
            m_gid = 0;

            CCTMXTiledMap map = CCTMXTiledMap.tiledMapWithTMXFile("TileMaps/orthogonal-test2");

            addChild(map, 0, TileMapTestScene.kTagTileMap);

            CCSize s = map.contentSize;
            ////----UXLOG("ContentSize: %f, %f", s.width,s.height);


            CCTMXLayer layer = map.layerNamed("Layer 0");

            layer.Texture.setAntiAliasTexParameters();

            map.scale = 1;

            CCSprite tile0 = layer.tileAt(new CCPoint(1, 63));
            CCSprite tile1 = layer.tileAt(new CCPoint(2, 63));
            CCSprite tile2 = layer.tileAt(new CCPoint(3, 62));//ccp(1,62));
            CCSprite tile3 = layer.tileAt(new CCPoint(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);

            CCActionInterval   move      = CCMoveBy.actionWithDuration(0.5f, new CCPoint(0, 160));
            CCActionInterval   rotate    = CCRotateBy.actionWithDuration(2, 360);
            CCActionInterval   scale     = CCScaleBy.actionWithDuration(2, 5);
            CCActionInterval   opacity   = CCFadeOut.actionWithDuration(2);
            CCActionInterval   fadein    = CCFadeIn.actionWithDuration(2);
            CCActionInterval   scaleback = CCScaleTo.actionWithDuration(1, 1);
            CCActionInstant    finish    = CCCallFuncN.actionWithTarget(this, removeSprite);
            CCFiniteTimeAction seq0      = CCSequence.actions(move, rotate, scale, opacity, fadein, scaleback, finish);
            CCActionInterval   seq1      = (CCActionInterval)(seq0.copy());
            CCActionInterval   seq2      = (CCActionInterval)(seq0.copy());
            CCActionInterval   seq3      = (CCActionInterval)(seq0.copy());

            tile0.runAction(seq0);
            tile1.runAction(seq1);
            tile2.runAction(seq2);
            tile3.runAction(seq3);


            m_gid = layer.tileGIDAt(new CCPoint(0, 63));
            ////----UXLOG("Tile GID at:(0,63) is: %d", m_gid);

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

            ////----UXLOG("++++atlas quantity: %d", layer->textureAtlas()->getTotalQuads());
            ////----UXLOG("++++children: %d", layer->getChildren()->count() );

            m_gid2 = 0;
        }
示例#4
0
        public TMXIsoVertexZ()
        {
            map = new CCTMXTiledMap("TileMaps/iso-test-vertexz");
            AddChild(map, 0, kTagTileMap);

            // because I'm lazy, I'm reusing a tile as an sprite, but since this method uses vertexZ, you
            // can use any CCSprite and it will work OK.
            CCTMXLayer layer = map.LayerNamed("Trees");

            m_tamara = layer.TileAt(29, 29);
        }
示例#5
0
        public void removeSprite(float dt)
        {
            unschedule(removeSprite);

            CCTMXTiledMap map   = (CCTMXTiledMap)getChildByTag(TileMapTestScene.kTagTileMap);
            CCTMXLayer    layer = map.layerNamed("Layer 0");
            CCSize        s     = layer.LayerSize;

            CCSprite sprite = layer.tileAt(new CCPoint(s.width - 1, 0));

            layer.removeChild(sprite, true);
        }
示例#6
0
        public TMXOrthoVertexZ()
        {
            CCTMXTiledMap map = new CCTMXTiledMap("TileMaps/orthogonal-test-vertexz");

            AddChild(map, 0, kTagTileMap);

            // because I'm lazy, I'm reusing a tile as an sprite, but since this method uses vertexZ, you
            // can use any CCSprite and it will work OK.
            CCTMXLayer layer = map.LayerNamed("trees");

            m_tamara = layer.TileAt(0, 11);
            CCLog.Log("tamara vertexZ: {0}", m_tamara.VertexZ);
        }
示例#7
0
        void removeTiles(float dt)
        {
            unschedule(removeTiles);

            CCTMXTiledMap map   = (CCTMXTiledMap)getChildByTag(TileMapTestScene.kTagTileMap);
            CCTMXLayer    layer = (CCTMXLayer)map.getChildByTag(0);
            CCSize        s     = layer.LayerSize;;

            for (int y = 0; y < s.height; y++)
            {
                layer.removeTileAt(new CCPoint(5.0f, (float)y));
            }
        }
示例#8
0
        public TMXReadWriteTest()
        {
            m_gid = 0;

            CCTMXTiledMap map = new CCTMXTiledMap("TileMaps/orthogonal-test2");

            AddChild(map, 0, kTagTileMap);

            CCTMXLayer layer = map.LayerNamed("Layer 0");

            layer.IsAntialiased = true;

            map.Scale = (1);

            CCSprite tile0 = layer.TileAt(new CCPoint(1, 63));
            CCSprite tile1 = layer.TileAt(new CCPoint(2, 63));
            CCSprite tile2 = layer.TileAt(new CCPoint(3, 62)); //new CCPoint(1,62));
            CCSprite tile3 = layer.TileAt(new CCPoint(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.TileGIDAt(new CCPoint(0, 63));
            ////----UXLOG("Tile GID at:(0,63) is: %d", m_gid);

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

            ////----UXLOG("++++atlas quantity: %d", layer.textureAtlas().getTotalQuads());
            ////----UXLOG("++++children: %d", layer.getChildren().count() );

            m_gid2 = 0;
        }
示例#9
0
        private void flipIt(float dt)
        {
            var        map   = (CCTMXTiledMap)this[kTagTileMap];
            CCTMXLayer layer = map.LayerNamed("Layer 0");

            //blue diamond
            var  tileCoord = new CCPoint(1, 10);
            uint flags;
            uint GID = layer.TileGIDAt(tileCoord, out flags);

            // Vertical
            if ((flags & CCTMXTileFlags.Vertical) != 0)
            {
                flags &= ~CCTMXTileFlags.Vertical;
            }
            else
            {
                flags |= CCTMXTileFlags.Vertical;
            }
            layer.SetTileGID(GID, tileCoord, flags);


            tileCoord = new CCPoint(1, 8);
            GID       = layer.TileGIDAt(tileCoord, out flags);
            // Vertical
            if ((flags & CCTMXTileFlags.Vertical) != 0)
            {
                flags &= ~CCTMXTileFlags.Vertical;
            }
            else
            {
                flags |= CCTMXTileFlags.Vertical;
            }
            layer.SetTileGID(GID, tileCoord, flags);


            tileCoord = new CCPoint(2, 8);
            GID       = layer.TileGIDAt(tileCoord, out flags);
            // Horizontal
            if ((flags & CCTMXTileFlags.Horizontal) != 0)
            {
                flags &= ~CCTMXTileFlags.Horizontal;
            }
            else
            {
                flags |= CCTMXTileFlags.Horizontal;
            }
            layer.SetTileGID(GID, tileCoord, flags);
        }
示例#10
0
        void repaintWithGID(float dt)
        {
            //	[self unschedule:_cmd);

            CCTMXTiledMap map   = (CCTMXTiledMap)getChildByTag(TileMapTestScene.kTagTileMap);
            CCTMXLayer    layer = (CCTMXLayer)map.getChildByTag(0);

            CCSize s = layer.LayerSize;

            for (int x = 0; x < s.width; x++)
            {
                int y      = (int)s.height - 1;
                int tmpgid = layer.tileGIDAt(new CCPoint((float)x, (float)y));
                layer.setTileGID(tmpgid + 1, new CCPoint((float)x, (float)y));
            }
        }
示例#11
0
        void updateCol(float dt)
        {
            CCTMXTiledMap map   = (CCTMXTiledMap)getChildByTag(TileMapTestScene.kTagTileMap);
            CCTMXLayer    layer = (CCTMXLayer)map.getChildByTag(0);

            ////----UXLOG("++++atlas quantity: %d", layer->textureAtlas()->getTotalQuads());
            ////----UXLOG("++++children: %d", layer->getChildren()->count() );


            CCSize s = layer.LayerSize;

            for (int y = 0; y < s.height; y++)
            {
                layer.setTileGID(m_gid2, new CCPoint((float)3, (float)y));
            }

            m_gid2 = (m_gid2 + 1) % 80;
        }
        public TMXTilesetTest()
        {
            CCTMXTiledMap map = CCTMXTiledMap.tiledMapWithTMXFile("TileMaps/orthogonal-test5");

            addChild(map, 0, TileMapTestScene.kTagTileMap);

            CCSize s = map.contentSize;
            ////----UXLOG("ContentSize: %f, %f", s.width,s.height);

            CCTMXLayer layer = map.layerNamed("Layer 0");

            layer.Texture.setAntiAliasTexParameters();

            layer = map.layerNamed("Layer 1");
            layer.Texture.setAntiAliasTexParameters();

            layer = map.layerNamed("Layer 2");
            layer.Texture.setAntiAliasTexParameters();
        }
示例#13
0
        public TMXResizeTest()
        {
            CCTMXTiledMap map = CCTMXTiledMap.tiledMapWithTMXFile("TileMaps/orthogonal-test5");

            addChild(map, 0, TileMapTestScene.kTagTileMap);

            CCSize s = map.contentSize;
            ////----UXLOG("ContentSize: %f, %f", s.width,s.height);

            CCTMXLayer layer = map.layerNamed("Layer 0");

            CCSize ls = layer.LayerSize;

            for (int y = 0; y < ls.height; y++)
            {
                for (int x = 0; x < ls.width; x++)
                {
                    layer.setTileGID(1, new CCPoint(x, y));
                }
            }
        }
示例#14
0
        public TMXOrthoTest4()
        {
            CCTMXTiledMap map = CCTMXTiledMap.tiledMapWithTMXFile("TileMaps/orthogonal-test4");

            addChild(map, 0, TileMapTestScene.kTagTileMap);

            CCSize s1 = map.contentSize;

            ////----UXLOG("ContentSize: %f, %f", s1.width,s1.height);

            foreach (var pObject in map.children)
            {
                CCSpriteBatchNode child = (CCSpriteBatchNode)pObject;

                if (child == null)
                {
                    break;
                }

                child.Texture.setAntiAliasTexParameters();
            }

            map.anchorPoint = new CCPoint(0, 0);

            CCTMXLayer layer = map.layerNamed("Layer 0");
            CCSize     s     = layer.LayerSize;

            CCSprite sprite = layer.tileAt(new CCPoint(0, 0));

            sprite.scale = 2;
            sprite       = layer.tileAt(new CCPoint(s.width - 1, 0));
            sprite.scale = 2;
            sprite       = layer.tileAt(new CCPoint(0, s.height - 1));
            sprite.scale = 2;
            sprite       = layer.tileAt(new CCPoint(s.width - 1, s.height - 1));
            sprite.scale = 2;

            schedule(removeSprite, 2);
        }
示例#15
0
        public TMXBug987()
        {
            CCTMXTiledMap map = new CCTMXTiledMap("TileMaps/orthogonal-test6");

            AddChild(map, 0, kTagTileMap);

            /*
             * CCArray* childs = map.getChildren();
             * CCTMXLayer* node;
             * object* pObject = NULL;
             * CCARRAY_FOREACH(childs, pObject)
             * {
             *  node = (CCTMXLayer*) pObject;
             *  CC_BREAK_IF(!node);
             *  node.Texture.setAntiAliasTexParameters();
             * }
             */

            map.AnchorPoint = CCPoint.AnchorLowerLeft;
            CCTMXLayer layer = map.LayerNamed("Tile Layer 1");

            layer.SetTileGID(3, new CCPoint(2, 2));
        }
示例#16
0
        public TMXOrthoVertexZ()
        {
            CCTMXTiledMap map = CCTMXTiledMap.tiledMapWithTMXFile("TileMaps/orthogonal-test-vertexz");

            addChild(map, 0, TileMapTestScene.kTagTileMap);

            CCSize s = map.contentSize;
            ////----UXLOG("ContentSize: %f, %f", s.width,s.height);

            // because I'm lazy, I'm reusing a tile as an sprite, but since this method uses vertexZ, you
            // can use any CCSprite and it will work OK.
            CCTMXLayer layer = map.layerNamed("trees");

            m_tamara = layer.tileAt(new CCPoint(0, 11));
            CCLog.Log("{0} vertexZ: {1}", m_tamara, m_tamara.vertexZ);

            CCActionInterval   move = CCMoveBy.actionWithDuration(10, CCPointExtension.ccpMult(new CCPoint(400, 450), 1 / CCDirector.sharedDirector().ContentScaleFactor));
            CCFiniteTimeAction back = move.reverse();
            CCFiniteTimeAction seq  = CCSequence.actions(move, back);

            m_tamara.runAction(CCRepeatForever.actionWithAction((CCActionInterval)seq));

            schedule(repositionSprite);
        }
示例#17
0
        public TMXOrthoTest4()
        {
            CCTMXTiledMap map = new CCTMXTiledMap("TileMaps/orthogonal-test4");

            AddChild(map, 0, kTagTileMap);

            map.AnchorPoint = CCPoint.AnchorLowerLeft;

            CCTMXLayer layer = map.LayerNamed("Layer 0");
            CCSize     s     = layer.LayerSize;

            CCSprite sprite;

            sprite       = layer.TileAt(0, 0);
            sprite.Scale = 2;
            sprite       = layer.TileAt(s.Width - 1, 0);
            sprite.Scale = 2;
            sprite       = layer.TileAt(0, s.Height - 1);
            sprite.Scale = 2;
            sprite       = layer.TileAt(s.Width - 1, s.Height - 1);
            sprite.Scale = 2;

            Schedule(removeSprite, 2);
        }