public TMXIsoZorder() { CCTMXTiledMap map = CCTMXTiledMap.tiledMapWithTMXFile("TileMaps/iso-test-zorder"); addChild(map, 0, 1); CCSize s = map.contentSize; ////----UXLOG("ContentSize: %f, %f", s.width,s.height); map.position = (new CCPoint(-s.width / 2, 0)); m_tamara = CCSprite.spriteWithFile(s_pPathSister1); map.addChild(m_tamara, map.children.Count); int mapWidth = (int)(map.MapSize.width * map.TileSize.width); m_tamara.positionInPixels = new CCPoint(mapWidth / 2, 0); m_tamara.anchorPoint = new CCPoint(0.5f, 0); 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((this.repositionSprite)); }
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)); }
public TMXIsoObjectsTest() { CCTMXTiledMap map = new CCTMXTiledMap("TileMaps/iso-test-objectgroup"); AddChild(map, -1, kTagTileMap); CCSize s = map.ContentSize; CCLog.Log("ContentSize: {0}, {1}", s.Width, s.Height); var objectGroup = map.ObjectGroupNamed("Object Group 1"); var objects = objectGroup.Objects; var drawNode = new CCDrawNode(); foreach (var dict in objects) { float x = float.Parse(dict["x"]); float y = float.Parse(dict["y"]); float width = (dict.ContainsKey("width") ? float.Parse(dict["width"]) : 0f); float height = (dict.ContainsKey("height") ? float.Parse(dict["height"]) : 0f); var color = new CCColor4B(255, 255, 255, 255); drawNode.DrawRect(new CCRect(x, y, width, height), CCColor4B.Transparent, 1, color); } map.AddChild(drawNode, 10); }
public TMXOrthoObjectsTest() { CCTMXTiledMap map = CCTMXTiledMap.tiledMapWithTMXFile("TileMaps/ortho-objects"); addChild(map, -1, 1); CCSize s = map.contentSize; ////----UXLOG("ContentSize: %f, %f", s.width,s.height); ////----UXLOG("----> Iterating over all the group objets"); CCTMXObjectGroup group = map.objectGroupNamed("Object Group 1"); List <Dictionary <string, string> > objects = group.Objects; Dictionary <string, string> dict; for (int i = 0; i < objects.Count; i++) { dict = objects[i];//dynamic_cast<CCStringToStringDictionary*>(*it); if (dict == null) { break; } ////----UXLOG("object: %x", dict); } ////----UXLOG("----> Fetching 1 object by name"); // CCStringToStringDictionary* platform = group->objectNamed("platform"); ////----UXLOG("platform: %x", platform); }
public TMXUncompressedTest() { CCLayerColor color = CCLayerColor.layerWithColor(new ccColor4B(64, 64, 64, 255)); addChild(color, -1); CCTMXTiledMap map = CCTMXTiledMap.tiledMapWithTMXFile("TileMaps/iso-test2-uncompressed"); addChild(map, 0, TileMapTestScene.kTagTileMap); CCSize s = map.contentSize; ////----UXLOG("ContentSize: %f, %f", s.width,s.height); // move map to the center of the screen CCSize ms = map.MapSize; CCSize ts = map.TileSize; map.runAction(CCMoveTo.actionWithDuration(1.0f, new CCPoint(-ms.width * ts.width / 2, -ms.height * ts.height / 2))); // testing release map CCTMXLayer layer; foreach (var pObject in map.children) { layer = (CCTMXLayer)pObject; if (layer == null) { break; } layer.releaseMap(); } }
public TMXOrthoTest2() { CCTMXTiledMap map = CCTMXTiledMap.tiledMapWithTMXFile("TileMaps/orthogonal-test1"); addChild(map, 0, TileMapTestScene.kTagTileMap); CCSize s = map.contentSize; ////----UXLOG("ContentSize: %f, %f", s.width,s.height); List <CCNode> pChildrenArray = map.children; CCSpriteBatchNode child = null; CCObject pObject = null; if (pChildrenArray != null && pChildrenArray.Count > 0) { for (int i = 0; i < pChildrenArray.Count; i++) { pObject = pChildrenArray[i]; child = (CCSpriteBatchNode)pObject; if (child == null) { break; } //child.Texture.setAntiAliasTexParameters(); } } map.runAction(CCScaleBy.actionWithDuration(2, 0.5f)); }
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); }
public SceneGame() { base.init(); //背景图 //CCSprite background = CCSprite.spriteWithSpriteFrameName("bg_game.png"); //background.anchorPoint = new CCPoint(0, 0); //this.addChild(background); //地图 CCTMXTiledMap map = CCTMXTiledMap.tiledMapWithTMXFile("TileMaps/Level0"); //map.removeChild(map.layerNamed("units"),false); //取得宽高 CCSize size = CCDirector.sharedDirector().getWinSize(); //保证地图是居中地图显示 map.position = new CCPoint((size.width - map.contentSize.width) / 2, (size.height - map.contentSize.height) / 2); this.addChild(map); //返回按钮 CCMenuItemSprite btn_attack = CCMenuItemSprite.itemFromNormalSprite( CCSprite.spriteWithSpriteFrameName("btn_soldierattack1.png"), CCSprite.spriteWithSpriteFrameName("btn_soldierattack2.png"), this, click_attack); CCMenu menu = CCMenu.menuWithItems(btn_attack); menu.position = new CCPoint(732, 36); this.addChild(menu); }
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 TMXIsoObjectsTest() { CCTMXTiledMap map = CCTMXTiledMap.tiledMapWithTMXFile("TileMaps/iso-test-objectgroup"); addChild(map, -1, 1); CCSize s = map.contentSize; ////----UXLOG("ContentSize: %f, %f", s.width,s.height); CCTMXObjectGroup group = map.objectGroupNamed("Object Group 1"); //UxMutableArray* objects = group->objects(); List <Dictionary <string, string> > objects = group.Objects; //UxMutableDictionary<std::string>* dict; Dictionary <string, string> dict; //CCMutableArray<CCObject*>::CCMutableArrayIterator it; for (int i = 0; i < objects.Count; i++) { dict = objects[i]; if (dict == null) { break; } } }
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); var scale = new CCScaleBy(10, 0.1f); var back = scale.Reverse(); map.RepeatForever(scale, back); //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 = CCTMXTiledMap.tiledMapWithTMXFile("TileMaps/orthogonal-test-movelayer"); addChild(map, 0, 1); CCSize s = map.contentSize; }
public TMXBug787() { CCTMXTiledMap map = CCTMXTiledMap.tiledMapWithTMXFile("TileMaps/iso-test-bug787"); addChild(map, 0, 1); map.scale = 0.25f; }
public TMXBug787() { CCTMXTiledMap map = new CCTMXTiledMap("TileMaps/iso-test-bug787"); AddChild(map, 0, kTagTileMap); map.Scale = (0.25f); }
public TMXIsoMoveLayer() { CCTMXTiledMap map = new CCTMXTiledMap("TileMaps/iso-test-movelayer"); AddChild(map, 0, kTagTileMap); map.Position = new CCPoint(-700, -50); }
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; }
public TMXIsoMoveLayer() { CCTMXTiledMap map = CCTMXTiledMap.tiledMapWithTMXFile("TileMaps/iso-test-movelayer"); addChild(map, 0, TileMapTestScene.kTagTileMap); map.position = new CCPoint(-700, -50); CCSize s = map.contentSize; }
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 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 TMXGIDObjectsTest() { CCTMXTiledMap map = CCTMXTiledMap.tiledMapWithTMXFile("TileMaps/test-object-layer"); addChild(map, -1, 1); CCSize s = map.contentSize; CCLog.Log("Contentsize: %f, %f", s.width, s.height); CCLog.Log("----> Iterating over all the group objets"); }
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); }
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; }
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)); } }
public TMXHexTest() { CCLayerColor color = CCLayerColor.layerWithColor(new ccColor4B(64, 64, 64, 255)); addChild(color, -1); CCTMXTiledMap map = CCTMXTiledMap.tiledMapWithTMXFile("TileMaps/hexa-test1"); addChild(map, 0, 1); CCSize s = map.contentSize; ////----UXLOG("ContentSize: %f, %f", s.width,s.height); }
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 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 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); }
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)); } }