Пример #1
0
        public static CCPoint GetTilePosition(CCTMXTiledMap tileMap, string tileName)
        {
            CCTMXObjectGroup objectGroup = tileMap.ObjectGroupNamed("Objects");
            if (objectGroup == null)
            {
                CCLog("tile map has no objects object layer");
                return CCPoint.Zero;
            }

            var spawnPoint = objectGroup.ObjectNamed(tileName);
            string x;
            spawnPoint.TryGetValue("x", out x);
            string y;
            spawnPoint.TryGetValue("y", out y);

            return new CCPoint((float)Convert.ToDouble(x), (float)Convert.ToDouble(y));
        }
Пример #2
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);
        }
Пример #3
0
        public TMXResizeTest()
        {
            CCTMXTiledMap map = new CCTMXTiledMap("TileMaps/orthogonal-test5");
            AddChild(map, 0, kTagTileMap);

            CCSize s = map.ContentSize;

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

            CCSize ls = layer.LayerSize;
            for (uint y = 0; y < ls.Height; y++)
            {
                for (uint x = 0; x < ls.Width; x++)
                {
                    layer.SetTileGID(1, new CCPoint(x, y));
                }
            }
        }
Пример #4
0
		public TMXOrthoZorder()
        {
            CCTMXTiledMap map = new CCTMXTiledMap("TileMaps/orthogonal-test-zorder");
            AddChild(map, 0, kTagTileMap);

            m_tamara = new CCSprite(pathSister1);
            map.AddChild(m_tamara, map.Children.Count);
			m_tamara.AnchorPoint = CCPoint.AnchorMiddleBottom;

			m_tamara.RepeatForever(move, back);

            Schedule(repositionSprite);
        }
Пример #5
0
        public TMXUncompressedTest()
        {
            CCLayerColor color = new CCLayerColor(new CCColor4B(64, 64, 64, 255));
            AddChild(color, -1);

            CCTMXTiledMap map = new CCTMXTiledMap("TileMaps/iso-test2-uncompressed");
            AddChild(map, 0, kTagTileMap);

            CCSize s = map.ContentSize;

            // move map to the center of the screen
            CCSize ms = map.MapSize;
            CCSize ts = map.TileSize;
            map.RunAction(new CCMoveTo (1.0f, new CCPoint(-ms.Width * ts.Width / 2, -ms.Height * ts.Height / 2)));

            /*
            // testing release map
            CCArray* pChildrenArray = map.getChildren();
            CCTMXLayer layer;
            object* pObject = NULL;
            CCARRAY_FOREACH(pChildrenArray, pObject)
            {
                layer = (CCTMXLayer) pObject;

                if (!layer)
                    break;

                layer.releaseMap();
            }
            */
        }
Пример #6
0
        public TMXOrthoObjectsTest()
        {
            CCTMXTiledMap map = new CCTMXTiledMap("TileMaps/ortho-objects");
            AddChild(map, -1, kTagTileMap);

            CCSize s = map.ContentSize;

            /*
            ////----UXLOG("---. Iterating over all the group objets");
            CCTMXObjectGroup group = map.objectGroupNamed("Object Group 1");
            CCArray objects = group.getObjects();

            CCDictionary* dict = NULL;
            object* pObj = NULL;
            CCARRAY_FOREACH(objects, pObj)
            {
                dict = (CCDictionary*) pObj; //dynamic_cast<CCStringToStringDictionary*>(*it);

                if (!dict)
                    break;

                ////----UXLOG("object: %x", dict);
            }
            */

            ////----UXLOG("---. Fetching 1 object by name");
            // CCStringToStringDictionary* platform = group.objectNamed("platform");
            ////----UXLOG("platform: %x", platform);
        }
Пример #7
0
        public TMXOrthoFlipRunTimeTest()
        {
            CCTMXTiledMap map = new CCTMXTiledMap("TileMaps/ortho-rotation-test");
            AddChild(map, 0, kTagTileMap);

			foreach (var mapChild in map.Children)
			{
				var child = (CCSpriteBatchNode)mapChild;
				child.Texture.IsAntialiased = true;
			}
				
			map.RunAction(SCALE_2X_Half );

            Schedule(flipIt, 1.0f);
        }
Пример #8
0
        public TMXIsoTest1()
        {
            CCLayerColor color = new CCLayerColor(new CCColor4B(64, 64, 64, 255));
            AddChild(color, -1);

            CCTMXTiledMap map = new CCTMXTiledMap("TileMaps/iso-test11");
            AddChild(map, 0, kTagTileMap);

            CCSize s = map.ContentSize;

            map.AnchorPoint = (new CCPoint(0.5f, 0.5f));
        }
Пример #9
0
        public TMXTilePropertyTest()
        {
            CCTMXTiledMap map = new CCTMXTiledMap("TileMaps/ortho-tile-property");
            AddChild(map, 0, kTagTileMap);

            for (uint i = 1; i <= 20; i++)
            {
				CCLog.Log("GID:{0}, Properties:{1}", i, map.PropertiesForGID(i));
            }
        }
Пример #10
0
        public TMXOrthoTest()
        {
            //
            // Test orthogonal with 3d camera and anti-alias textures
            //
            // it should not flicker. No artifacts should appear
            //
            //CCLayerColor* color = new CCLayerColor( ccc4(64,64,64,255) );
            //addChild(color, -1);

            CCTMXTiledMap map = new CCTMXTiledMap("TileMaps/orthogonal-test2");
            AddChild(map, 0, kTagTileMap);

            CCSize s = map.ContentSize;
            CCLog.Log("ContentSize: {0}, {1}", s.Width, s.Height);

            /*
            CCArray pChildrenArray = map.getChildren();
            CCSpriteBatchNode* child = NULL;
            object* pObject = NULL;
            CCARRAY_FOREACH(pChildrenArray, pObject)
            {
                child = (CCSpriteBatchNode*) pObject;

                if (!child)
                    break;

                child.Texture.setAntiAliasTexParameters();
            }
            */

            float x, y, z;
            //map.Camera.GetEyeXyz(out x, out y, out z);
            //map.Camera.SetEyeXyz(x - 200, y, z + 300);
        }
Пример #11
0
 public TMXOrthoMoveLayer()
 {
     CCTMXTiledMap map = new CCTMXTiledMap("TileMaps/orthogonal-test-movelayer");
     AddChild(map, 0, kTagTileMap);
 }
Пример #12
0
        public TMXIsoMoveLayer()
        {
            CCTMXTiledMap map = new CCTMXTiledMap("TileMaps/iso-test-movelayer");
            AddChild(map, 0, kTagTileMap);

            map.Position = new CCPoint(-700, -50);
        }
Пример #13
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);
        }
Пример #14
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;
        }
Пример #15
0
        public TMXOrthoFromXMLTest()
        {
            CCTMXTiledMap map = new CCTMXTiledMap("TileMaps/orthogonal-test1");
            AddChild(map, 0, kTagTileMap);

			foreach (var mapChild in map.Children)
			{
				var child = (CCSpriteBatchNode)mapChild;
				child.Texture.IsAntialiased = true;
			}
				
			map.RunAction(SCALE_2X_Half );
        }
Пример #16
0
        public TMXHexTest()
        {
            CCLayerColor color = new CCLayerColor(new CCColor4B(64, 64, 64, 255));
            AddChild(color, -1);

            CCTMXTiledMap map = new CCTMXTiledMap("TileMaps/hexa-test1");
            AddChild(map, 0, kTagTileMap);

            CCSize s = map.ContentSize;
        }
Пример #17
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));

        }
Пример #18
0
        public TMXIsoTest2()
        {
            CCLayerColor color = new CCLayerColor(new CCColor4B(64, 64, 64, 255));
            AddChild(color, -1);

            CCTMXTiledMap map = new CCTMXTiledMap("TileMaps/iso-test22");
            AddChild(map, 0, kTagTileMap);

            CCSize s = map.ContentSize;

            // move map to the center of the screen
            CCSize ms = map.MapSize;
            CCSize ts = map.TileSize;
            map.RunAction(new CCMoveTo (1.0f, new CCPoint(-ms.Width * ts.Width / 2, -ms.Height * ts.Height / 2)));
        }
Пример #19
0
        public TMXBug787()
        {
            CCTMXTiledMap map = new CCTMXTiledMap("TileMaps/iso-test-bug787");
            AddChild(map, 0, kTagTileMap);

            map.Scale = (0.25f);
        }
Пример #20
0
        public TMXTilesetTest()
        {
            CCTMXTiledMap map = new CCTMXTiledMap("TileMaps/orthogonal-test5");
            AddChild(map, 0, kTagTileMap);

            CCSize s = map.ContentSize;

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

            layer = map.LayerNamed("Layer 1");
			layer.IsAntialiased = true;

            layer = map.LayerNamed("Layer 2");
			layer.IsAntialiased = true;
        }
Пример #21
0
 public TMXGIDObjectsTest()
 {
     CCTMXTiledMap map = new CCTMXTiledMap("TileMaps/test-object-layer");
     AddChild(map, -1, kTagTileMap);
 }
Пример #22
0
        public TMXIsoObjectsTest()
        {
            CCTMXTiledMap map = new CCTMXTiledMap("TileMaps/iso-test-objectgroup");
            AddChild(map, -1, kTagTileMap);

            CCSize s = map.ContentSize;

            /*
            CCTMXObjectGroup group = map.objectGroupNamed("Object Group 1");

            //UxMutableArray* objects = group.objects();
            CCArray* objects = group.getObjects();
            //UxMutableDictionary<string>* dict;
            CCDictionary* dict;
            object* pObj = NULL;
            CCARRAY_FOREACH(objects, pObj)
            {
                dict = (CCDictionary*) pObj;

                if (!dict)
                    break;

                ////----UXLOG("object: %x", dict);
            }
            */
        }
Пример #23
0
        public TMXOrthoTest2()
        {
            CCTMXTiledMap map = new CCTMXTiledMap("TileMaps/orthogonal-test1");
            AddChild(map, 0, kTagTileMap);

            /*
            CCArray* pChildrenArray = map.getChildren();
            CCSpriteBatchNode* child = NULL;
            object* pObject = NULL;
            CCARRAY_FOREACH(pChildrenArray, pObject)
            {
                child = (CCSpriteBatchNode*) pObject;

                if (!child)
                    break;

                child.Texture.setAntiAliasTexParameters();
            }
            */

			map.RunAction(SCALE_2X_Half );
        }
Пример #24
0
        public TMXIsoZorder()
        {
            CCTMXTiledMap map = new CCTMXTiledMap("TileMaps/iso-test-zorder");
            AddChild(map, 0, kTagTileMap);

            CCSize s = map.ContentSize;
            CCLog.Log("ContentSize: {0}, {1}", s.Width, s.Height);

            m_tamara = new CCSprite(pathSister1);
            map.AddChild(m_tamara, map.Children.Count);

            m_tamara.AnchorPoint = (new CCPoint(0.5f, 0));

			m_tamara.RepeatForever(move, back);

            Schedule(repositionSprite);
        }
Пример #25
0
        public TMXOrthoTest3()
        {
            CCTMXTiledMap map = new CCTMXTiledMap("TileMaps/orthogonal-test3");
            AddChild(map, 0, kTagTileMap);

            /*
            CCArray* pChildrenArray = map.getChildren();
            CCSpriteBatchNode* child = NULL;
            object* pObject = NULL;
            CCARRAY_FOREACH(pChildrenArray, pObject)
            {
                child = (CCSpriteBatchNode*) pObject;

                if (!child)
                    break;

                child.Texture.setAntiAliasTexParameters();
            }
            */

            map.Scale = 0.2f;
            map.AnchorPoint = (new CCPoint(0.5f, 0.5f));
        }
Пример #26
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();
        }
Пример #27
0
        public TMXOrthoTest4()
        {
            CCTMXTiledMap map = new CCTMXTiledMap("TileMaps/orthogonal-test4");
            AddChild(map, 0, kTagTileMap);

            /*
            CCArray* pChildrenArray = map.getChildren();
            CCSpriteBatchNode* child = NULL;
            object* pObject = NULL;
            CCARRAY_FOREACH(pChildrenArray, pObject)
            {
                child = (CCSpriteBatchNode*) pObject;

                if (!child)
                    break;

                child.Texture.setAntiAliasTexParameters();
            }
            */

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

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

            CCSprite sprite;
            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);
        }
Пример #28
0
 protected override void AddedToScene()
 {
     base.AddedToScene();
     tileMap = new CCTMXTiledMap(TileMapTmxFile); // tileMap = new CCTMXTiledMap("pd_tilemap.tmx");
     AddChild(tileMap, -6);
 }
Пример #29
0
 public IntroLayer()
 {
     tileMap = new CCTMXTiledMap("TileMap.tmx");
     background = tileMap.LayerNamed("Background");
     AddChild(background);
 }