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)); }
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); }
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)); } } }
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); }
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(); } */ }
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); }
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); }
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)); }
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)); } }
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); }
public TMXOrthoMoveLayer() { CCTMXTiledMap map = new CCTMXTiledMap("TileMaps/orthogonal-test-movelayer"); AddChild(map, 0, kTagTileMap); }
public TMXIsoMoveLayer() { CCTMXTiledMap map = new CCTMXTiledMap("TileMaps/iso-test-movelayer"); AddChild(map, 0, kTagTileMap); map.Position = new CCPoint(-700, -50); }
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); }
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; }
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 ); }
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; }
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)); }
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))); }
public TMXBug787() { CCTMXTiledMap map = new CCTMXTiledMap("TileMaps/iso-test-bug787"); AddChild(map, 0, kTagTileMap); map.Scale = (0.25f); }
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; }
public TMXGIDObjectsTest() { CCTMXTiledMap map = new CCTMXTiledMap("TileMaps/test-object-layer"); AddChild(map, -1, kTagTileMap); }
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); } */ }
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 ); }
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); }
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)); }
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(); }
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); }
protected override void AddedToScene() { base.AddedToScene(); tileMap = new CCTMXTiledMap(TileMapTmxFile); // tileMap = new CCTMXTiledMap("pd_tilemap.tmx"); AddChild(tileMap, -6); }
public IntroLayer() { tileMap = new CCTMXTiledMap("TileMap.tmx"); background = tileMap.LayerNamed("Background"); AddChild(background); }