26#include "../testResource.h"
43TileMapTests::TileMapTests()
90 Director::getInstance()->getRenderer()->setDepthTest(
true);
91 Director::getInstance()->getRenderer()->setDepthWrite(
true);
92 Director::getInstance()->getRenderer()->setDepthCompareFunction(backend::CompareFunction::LESS_EQUAL);
94 auto listener = EventListenerTouchAllAtOnce::create();
96 _eventDispatcher->addEventListenerWithSceneGraphPriority(listener,
this);
110 return "drag the screen";
116 Director::getInstance()->getRenderer()->setDepthTest(
false);
117 Director::getInstance()->getRenderer()->setDepthWrite(
false);
122 auto touch = touches[0];
124 auto diff = touch->getDelta();
126 auto currentPos = node->getPosition();
127 node->setPosition(currentPos + diff);
139 map->getTexture()->setAntiAliasTexParameters();
141 Size CC_UNUSED s = map->getContentSize();
142 CCLOG(
"ContentSize: %f, %f", s.width,s.height);
150 map->setAnchorPoint( Vec2(0.0f, 0.5f) );
152 auto scale = ScaleBy::create(4, 0.8f);
153 auto scaleBack = scale->reverse();
155 auto seq = Sequence::create(scale, scaleBack,
nullptr);
157 map->runAction(RepeatForever::create(seq));
162 return "TileMapAtlas";
174 map->getTexture()->setAliasTexParameters();
176 Size CC_UNUSED s = map->getContentSize();
177 CCLOG(
"ContentSize: %f, %f", s.width,s.height);
186 map->setAnchorPoint( Vec2(0, 0) );
187 map->setPosition( Vec2(-20,-200) );
196 auto tilemap = (TileMapAtlas*) getChildByTag(
kTagTileMap);
212 Color3B c = tilemap->getTileAt(Vec2(13,21));
219 tilemap->setTile(c, Vec2(13,21) );
224 return "Editable TileMapAtlas";
242 auto map = TMXTiledMap::create(
"TileMaps/orthogonal-test2.tmx");
246 Size CC_UNUSED s = map->getContentSize();
247 CCLOG(
"ContentSize: %f, %f", s.width,s.height);
249 auto scale = ScaleBy::create(10, 0.1f);
250 auto back = scale->reverse();
251 auto seq = Sequence::create(scale, back,
nullptr);
252 auto repeat = RepeatForever::create(seq);
253 map->runAction(repeat);
264 Director::getInstance()->setProjection(Director::Projection::_3D);
269 Director::getInstance()->setProjection(Director::Projection::DEFAULT);
275 return "TMX Orthogonal test";
281 auto map = TMXTiledMap::create(
"TileMaps/test-staggered.tmx");
291 Director::getInstance()->setProjection(Director::Projection::_3D);
296 Director::getInstance()->setProjection(Director::Projection::DEFAULT);
302 return "TMX Staggered test";
312 auto map = TMXTiledMap::create(
"TileMaps/orthogonal-test1.tmx");
315 Size CC_UNUSED s = map->getContentSize();
316 CCLOG(
"ContentSize: %f, %f", s.width,s.height);
318 auto& children = map->getChildren();
319 SpriteBatchNode* child =
nullptr;
321 for(
const auto &obj : children) {
322 child =
static_cast<SpriteBatchNode*
>(obj);
323 child->getTexture()->setAntiAliasTexParameters();
326 map->runAction( ScaleBy::create(2, 0.5f) ) ;
331 return "TMX Ortho test2";
341 auto map = TMXTiledMap::create(
"TileMaps/orthogonal-test3.tmx");
344 Size CC_UNUSED s = map->getContentSize();
345 CCLOG(
"ContentSize: %f, %f", s.width,s.height);
347 auto& children = map->getChildren();
348 SpriteBatchNode* child =
nullptr;
350 for(
const auto &node : children) {
351 child =
static_cast<SpriteBatchNode*
>(node);
352 child->getTexture()->setAntiAliasTexParameters();
356 map->setAnchorPoint( Vec2(0.5f, 0.5f) );
361 return "TMX anchorPoint test";
371 auto map = TMXTiledMap::create(
"TileMaps/orthogonal-test4.tmx");
374 Size CC_UNUSED s1 = map->getContentSize();
375 CCLOG(
"ContentSize: %f, %f", s1.width,s1.height);
377 SpriteBatchNode* child =
nullptr;
379 auto& children = map->getChildren();
381 for(
const auto &node : children) {
382 child =
static_cast<SpriteBatchNode*
>(node);
383 child->getTexture()->setAntiAliasTexParameters();
386 map->setAnchorPoint(Vec2(0.0f, 0.0f));
388 auto layer = map->getLayer(
"Layer 0");
389 auto s = layer->getLayerSize();
391 layer->setOpacity(128);
394 sprite = layer->getTileAt(Vec2(0.0f,0.0f));
396 sprite = layer->getTileAt(Vec2(s.width-1,0.0f));
398 sprite = layer->getTileAt(Vec2(0.0f,s.height-1));
400 sprite = layer->getTileAt(Vec2(s.width-1,s.height-1));
411 auto map =
static_cast<TMXTiledMap*
>( getChildByTag(
kTagTileMap) );
412 auto layer = map->getLayer(
"Layer 0");
413 auto s = layer->getLayerSize();
415 auto sprite = layer->getTileAt( Vec2(s.width-1,0.0f) );
416 auto sprite2 = layer->getTileAt(Vec2(s.width-1, s.height-1));
417 layer->removeChild(sprite,
true);
418 auto sprite3 = layer->getTileAt(Vec2(2.0f, s.height-1));
419 layer->removeChild(sprite3,
true);
420 layer->removeChild(sprite2,
true);
425 return "TMX width/height test";
444 auto map = TMXTiledMap::create(
"TileMaps/orthogonal-test2.tmx");
447 Size CC_UNUSED s = map->getContentSize();
448 CCLOG(
"ContentSize: %f, %f", s.width,s.height);
451 auto layer = map->getLayer(
"Layer 0");
452 layer->getTexture()->setAntiAliasTexParameters();
456 auto tile0 = layer->getTileAt(Vec2(1,63));
457 auto tile1 = layer->getTileAt(Vec2(2,63));
458 auto tile2 = layer->getTileAt(Vec2(3,62));
459 auto tile3 = layer->getTileAt(Vec2(2,62));
460 tile0->setAnchorPoint( Vec2(0.5f, 0.5f) );
461 tile1->setAnchorPoint( Vec2(0.5f, 0.5f) );
462 tile2->setAnchorPoint( Vec2(0.5f, 0.5f) );
463 tile3->setAnchorPoint( Vec2(0.5f, 0.5f) );
465 auto move = MoveBy::create(0.5f, Vec2(0.0f,160.0f));
466 auto rotate = RotateBy::create(2, 360);
467 auto scale = ScaleBy::create(2, 5);
468 auto opacity = FadeOut::create(2);
469 auto fadein = FadeIn::create(2);
470 auto scaleback = ScaleTo::create(1, 1);
472 auto seq0 = Sequence::create(move, rotate, scale, opacity, fadein, scaleback, finish,
nullptr);
473 auto seq1 = seq0->clone();
474 auto seq2 = seq0->clone();
475 auto seq3 = seq0->clone();
477 tile0->runAction(seq0);
478 tile1->runAction(seq1);
479 tile2->runAction(seq2);
480 tile3->runAction(seq3);
483 _gid = layer->getTileGIDAt(Vec2(0,63));
499 auto p = ((Node*)sender)->getParent();
503 p->removeChild((Node*)sender,
true);
511 auto map = (TMXTiledMap*)getChildByTag(
kTagTileMap);
512 auto layer = (TMXLayer*)map->getChildByTag(0);
518 auto s = layer->getLayerSize();
520 for(
int y=0; y< s.height; y++ )
522 layer->setTileGID(
_gid2, Vec2((
float)3, (float)y));
532 auto map = (TMXTiledMap*)getChildByTag(
kTagTileMap);
533 auto layer = (TMXLayer*)map->getChildByTag(0);
535 auto s = layer->getLayerSize();
536 for(
int x=0; x<s.width;x++)
538 int y = (int)s.height-1;
539 unsigned int tmpgid = layer->getTileGIDAt( Vec2((
float)x, (float)y) );
540 layer->setTileGID(tmpgid+1, Vec2((
float)x, (float)y));
548 auto map = (TMXTiledMap*)getChildByTag(
kTagTileMap);
549 auto layer = (TMXLayer*)map->getChildByTag(0);
550 auto s = layer->getLayerSize();
552 for(
int y=0; y< s.height; y++ )
554 layer->removeTileAt( Vec2(5.0, (
float)y) );
562 return "TMX Read/Write test";
572 auto color = LayerColor::create( Color4B(64,64,64,255) );
575 auto map = TMXTiledMap::create(
"TileMaps/hexa-test.tmx");
578 Size CC_UNUSED s = map->getContentSize();
579 CCLOG(
"ContentSize: %f, %f", s.width,s.height);
584 return "TMX Hex tes";
594 auto color = LayerColor::create( Color4B(64,64,64,255) );
597 auto map = TMXTiledMap::create(
"TileMaps/iso-test.tmx");
601 auto ms = map->getMapSize();
602 auto ts = map->getTileSize();
603 map->runAction( MoveTo::create(1.0f, Vec2( -ms.width * ts.width/2, -ms.height * ts.height/2 )) );
608 return "TMX Isometric test 0";
618 auto color = LayerColor::create( Color4B(64,64,64,255) );
621 auto map = TMXTiledMap::create(
"TileMaps/iso-test1.tmx");
624 Size CC_UNUSED s = map->getContentSize();
625 CCLOG(
"ContentSize: %f, %f", s.width,s.height);
627 map->setAnchorPoint(Vec2(0.5f, 0.5f));
632 return "TMX Isometric test + anchorPoint";
642 auto color = LayerColor::create( Color4B(64,64,64,255) );
645 auto map = TMXTiledMap::create(
"TileMaps/iso-test2.tmx");
648 Size CC_UNUSED s = map->getContentSize();
649 CCLOG(
"ContentSize: %f, %f", s.width,s.height);
652 auto ms = map->getMapSize();
653 auto ts = map->getTileSize();
654 map->runAction( MoveTo::create(1.0f, Vec2( -ms.width * ts.width/2, -ms.height * ts.height/2 ) ));
659 return "TMX Isometric test 2";
669 auto color = LayerColor::create( Color4B(64,64,64,255) );
672 auto map = TMXTiledMap::create(
"TileMaps/iso-test2-uncompressed.tmx");
675 Size CC_UNUSED s = map->getContentSize();
676 CCLOG(
"ContentSize: %f, %f", s.width,s.height);
679 auto ms = map->getMapSize();
680 auto ts = map->getTileSize();
681 map->runAction(MoveTo::create(1.0f, Vec2( -ms.width * ts.width/2, -ms.height * ts.height/2 ) ));
686 auto& children = map->getChildren();
687 for(
const auto &node : children) {
688 layer=
static_cast<TMXLayer*
>(node);
696 return "TMX Uncompressed test";
706 auto map = TMXTiledMap::create(
"TileMaps/orthogonal-test5.tmx");
709 Size CC_UNUSED s = map->getContentSize();
710 CCLOG(
"ContentSize: %f, %f", s.width,s.height);
713 layer = map->getLayer(
"Layer 0");
714 layer->getTexture()->setAntiAliasTexParameters();
716 layer = map->getLayer(
"Layer 1");
717 layer->getTexture()->setAntiAliasTexParameters();
719 layer = map->getLayer(
"Layer 2");
720 layer->getTexture()->setAntiAliasTexParameters();
725 return "TMX Tileset test";
736 auto map = TMXTiledMap::create(
"TileMaps/orthogonal-test5-csv.tmx");
737 CCASSERT(map,
"Map was not created. Probably failed to parse!");
740 Size CC_UNUSED s = map->getContentSize();
741 CCLOG(
"ContentSize: %f, %f", s.width,s.height);
744 layer = map->getLayer(
"Layer 0");
745 layer->getTexture()->setAntiAliasTexParameters();
747 layer = map->getLayer(
"Layer 1");
748 layer->getTexture()->setAntiAliasTexParameters();
750 layer = map->getLayer(
"Layer 2");
751 layer->getTexture()->setAntiAliasTexParameters();
756 return "TMX CSV Parsing test";
766 auto map = TMXTiledMap::create(
"TileMaps/ortho-objects.tmx");
769 Size CC_UNUSED s = map->getContentSize();
770 CCLOG(
"ContentSize: %f, %f", s.width,s.height);
772 auto group = map->getObjectGroup(
"Object Group 1");
773 auto& objects = group->getObjects();
775 Value objectsVal = Value(objects);
776 CCLOG(
"%s", objectsVal.getDescription().c_str());
778 auto drawNode = DrawNode::create();
780 for (
auto& obj : objects)
782 ValueMap& dict = obj.asValueMap();
784 float x = dict[
"x"].asFloat();
785 float y = dict[
"y"].asFloat();
786 float width = dict[
"width"].asFloat();
787 float height = dict[
"height"].asFloat();
789 Color4F color(1.0, 1.0, 1.0, 1.0);
791 drawNode->drawLine( Vec2(x, y), Vec2((x+width), y), color );
792 drawNode->drawLine( Vec2((x+width), y), Vec2((x+width), (y+height)), color );
793 drawNode->drawLine( Vec2((x+width), (y+height)), Vec2(x, (y+height)), color );
794 drawNode->drawLine( Vec2(x, (y+height)), Vec2(x, y), color );
796 map->addChild(drawNode);
801 return "TMX Ortho object test";
806 return "You should see a white box around the 3 platforms";
818 auto map = TMXTiledMap::create(
"TileMaps/iso-test-objectgroup.tmx");
821 Size CC_UNUSED s = map->getContentSize();
822 CCLOG(
"ContentSize: %f, %f", s.width,s.height);
824 auto group = map->getObjectGroup(
"Object Group 1");
826 auto& objects = group->getObjects();
828 Value objectsVal = Value(objects);
829 CCLOG(
"%s", objectsVal.getDescription().c_str());
831 auto drawNode = DrawNode::create();
833 for (
auto& obj : objects)
835 ValueMap& dict = obj.asValueMap();
837 float x = dict[
"x"].asFloat();
838 float y = dict[
"y"].asFloat();
839 float width = dict[
"width"].asFloat();
840 float height = dict[
"height"].asFloat();
842 Color4F color(1.0, 1.0, 1.0, 1.0);
844 drawNode->drawLine( Vec2(x, y), Vec2((x+width), y), color );
845 drawNode->drawLine( Vec2((x+width), y), Vec2((x+width), (y+height)), color );
846 drawNode->drawLine( Vec2((x+width), (y+height)), Vec2(x, (y+height)), color );
847 drawNode->drawLine( Vec2(x, (y+height)), Vec2(x, y), color );
849 map->addChild(drawNode, 10);
854 return "TMX Iso object test";
859 return "You need to parse them manually. See bug #810";
871 auto map = TMXTiledMap::create(
"TileMaps/orthogonal-test5.tmx");
874 Size CC_UNUSED s = map->getContentSize();
875 CCLOG(
"ContentSize: %f, %f", s.width,s.height);
878 layer = map->getLayer(
"Layer 0");
880 auto ls = layer->getLayerSize();
881 for (
unsigned int y = 0; y < ls.height; y++)
883 for (
unsigned int x = 0; x < ls.width; x++)
885 layer->setTileGID(1, Vec2( (
float)x, (
float)y ) );
892 return "TMX resize test";
897 return "Should not crash. Testing issue #740";
908 Director::getInstance()->getRenderer()->setDepthTest(
false);
909 auto map = TMXTiledMap::create(
"TileMaps/iso-test-zorder.tmx");
912 auto s = map->getContentSize();
913 CCLOG(
"ContentSize: %f, %f", s.width,s.height);
914 map->setPosition(Vec2(-s.width/2,0.0f));
917 map->addChild(
_tamara, (
int)map->getChildren().size() );
920 int mapWidth = map->getMapSize().width * map->getTileSize().width;
921 _tamara->setPosition(CC_POINT_PIXELS_TO_POINTS(Vec2( mapWidth/2.0f,0.0f)));
923 _tamara->setAnchorPoint(Vec2(0.5f,0.0f));
926 auto move = MoveBy::create(10, Vec2(300.0f,250.0f));
927 auto back = move->reverse();
928 auto seq = Sequence::create(move, back,
nullptr);
929 _tamara->runAction( RepeatForever::create(seq) );
947 auto p =
_tamara->getPosition();
948 p = CC_POINT_POINTS_TO_PIXELS(p);
956 int newZ = 4 - (
static_cast<int>(p.y) / 30);
957 newZ = std::max(newZ,0);
959 map->reorderChild(
_tamara, newZ);
964 return "TMX Iso Zorder";
969 return "Sprite should hide behind the trees";
980 auto map = TMXTiledMap::create(
"TileMaps/orthogonal-test-zorder.tmx");
983 Size CC_UNUSED s = map->getContentSize();
984 CCLOG(
"ContentSize: %f, %f", s.width,s.height);
987 map->addChild(
_tamara, (
int)map->getChildren().size());
989 _tamara->setAnchorPoint(Vec2(0.5f,0.0f));
992 auto move = MoveBy::create(10, Vec2(400.0f,450.0f));
993 auto back = move->reverse();
994 auto seq = Sequence::create(move, back,
nullptr);
995 _tamara->runAction( RepeatForever::create(seq));
1007 auto p =
_tamara->getPosition();
1008 p = CC_POINT_POINTS_TO_PIXELS(p);
1017 int newZ = 4 - ( (p.y-10) / 81);
1018 newZ = std::max(newZ,0);
1020 map->reorderChild(
_tamara, newZ);
1025 return "TMX Ortho Zorder";
1030 return "Sprite should hide behind the trees";
1041 auto map = TMXTiledMap::create(
"TileMaps/iso-test-vertexz.tmx");
1044 auto s = map->getContentSize();
1045 map->setPosition( Vec2(-s.width/2,0.0f) );
1046 CCLOG(
"ContentSize: %f, %f", s.width,s.height);
1050 auto layer = map->getLayer(
"Trees");
1051 _tamara = layer->getTileAt( Vec2(29,29) );
1054 auto move = MoveBy::create(10, Vec2(300,250) * (1/CC_CONTENT_SCALE_FACTOR()));
1055 auto back = move->reverse();
1056 auto seq = Sequence::create(move, back,
nullptr);
1057 _tamara->runAction( RepeatForever::create(seq) );
1072 auto p =
_tamara->getPosition();
1073 p = CC_POINT_POINTS_TO_PIXELS(p);
1074 float newZ = -(p.y+32) /16;
1075 _tamara->setPositionZ( newZ );
1083 Director::getInstance()->setProjection(Director::Projection::_2D);
1084 Director::getInstance()->getRenderer()->setDepthTest(
true);
1085 Director::getInstance()->getRenderer()->setDepthWrite(
true);
1091 Director::getInstance()->setProjection(Director::Projection::DEFAULT);
1092 Director::getInstance()->getRenderer()->setDepthTest(
false);
1093 Director::getInstance()->getRenderer()->setDepthWrite(
false);
1100 return "TMX Iso VertexZ";
1105 return "Sprite should hide behind the trees";
1116 auto map = TMXTiledMap::create(
"TileMaps/orthogonal-test-vertexz.tmx");
1119 Size CC_UNUSED s = map->getContentSize();
1120 CCLOG(
"ContentSize: %f, %f", s.width,s.height);
1124 auto layer = map->getLayer(
"trees");
1125 _tamara = layer->getTileAt(Vec2(0,11));
1129 auto move = MoveBy::create(10, Vec2(400,450) * (1/CC_CONTENT_SCALE_FACTOR()));
1130 auto back = move->reverse();
1131 auto seq = Sequence::create(move, back,
nullptr);
1132 _tamara->runAction( RepeatForever::create(seq));
1147 auto p =
_tamara->getPosition();
1148 p = CC_POINT_POINTS_TO_PIXELS(p);
1149 _tamara->setPositionZ( -( (p.y+81) /81) );
1157 Director::getInstance()->setProjection(Director::Projection::_2D);
1158 Director::getInstance()->getRenderer()->setDepthTest(
true);
1159 Director::getInstance()->getRenderer()->setDepthWrite(
true);
1166 Director::getInstance()->setProjection(Director::Projection::DEFAULT);
1167 Director::getInstance()->getRenderer()->setDepthTest(
false);
1168 Director::getInstance()->getRenderer()->setDepthWrite(
false);
1174 return "TMX Ortho vertexZ";
1179 return "Sprite should hide behind the trees";
1190 auto map = TMXTiledMap::create(
"TileMaps/iso-test-movelayer.tmx");
1193 map->setPosition(Vec2(-700.0f,-50.0f));
1195 Size CC_UNUSED s = map->getContentSize();
1196 CCLOG(
"ContentSize: %f, %f", s.width,s.height);
1201 return "TMX Iso Move Layer";
1206 return "Trees should be horizontally aligned";
1217 auto map = TMXTiledMap::create(
"TileMaps/orthogonal-test-movelayer.tmx");
1220 Size CC_UNUSED s = map->getContentSize();
1221 CCLOG(
"ContentSize: %f, %f", s.width,s.height);
1226 return "TMX Ortho Move Layer";
1231 return "Trees should be horizontally aligned";
1242 auto map = TMXTiledMap::create(
"TileMaps/ortho-tile-property.tmx");
1245 for(
int i=1;i<=20;i++){
1246 for(
const auto& value : map->getPropertiesForGID(i).asValueMap())
1248 log(
"GID:%i, Properties:%s, %s", i, value.first.c_str(), value.second.asString().c_str());
1255 return "TMX Tile Property Test";
1260 return "In the console you should see tile properties";
1271 auto map = TMXTiledMap::create(
"TileMaps/ortho-rotation-test.tmx");
1274 Size CC_UNUSED s = map->getContentSize();
1275 log(
"ContentSize: %f, %f", s.width,s.height);
1277 auto& children = map->getChildren();
1278 for(
const auto &node : children) {
1279 auto child =
static_cast<SpriteBatchNode*
>(node);
1280 child->getTexture()->setAntiAliasTexParameters();
1283 auto action = ScaleBy::create(2, 0.5f);
1284 map->runAction(action);
1289 return "TMX tile flip test";
1300 auto map = TMXTiledMap::create(
"TileMaps/ortho-rotation-test.tmx");
1303 auto s = map->getContentSize();
1304 log(
"ContentSize: %f, %f", s.width,s.height);
1306 auto& children = map->getChildren();
1307 for(
const auto &node : children) {
1308 auto child =
static_cast<SpriteBatchNode*
>(node);
1309 child->getTexture()->setAntiAliasTexParameters();
1312 auto action = ScaleBy::create(2, 0.5f);
1313 map->runAction(action);
1320 return "TMX tile flip run time test";
1325 return "in 2 sec bottom left tiles will flip";
1330 auto map = (TMXTiledMap*) getChildByTag(
kTagTileMap);
1331 auto layer = map->getLayer(
"Layer 0");
1334 auto tileCoord = Vec2(1,10);
1336 unsigned int GID = layer->getTileGIDAt(tileCoord, (TMXTileFlags*)&flags);
1338 if( flags & kTMXTileVerticalFlag )
1339 flags &= ~kTMXTileVerticalFlag;
1341 flags |= kTMXTileVerticalFlag;
1342 layer->setTileGID(GID ,tileCoord, (TMXTileFlags)flags);
1345 tileCoord = Vec2(1,8);
1346 GID = layer->getTileGIDAt(tileCoord, (TMXTileFlags*)&flags);
1348 if( flags & kTMXTileVerticalFlag )
1349 flags &= ~kTMXTileVerticalFlag;
1351 flags |= kTMXTileVerticalFlag;
1352 layer->setTileGID(GID ,tileCoord, (TMXTileFlags)flags);
1355 tileCoord = Vec2(2,8);
1356 GID = layer->getTileGIDAt(tileCoord, (TMXTileFlags*)&flags);
1358 if( flags & kTMXTileHorizontalFlag )
1359 flags &= ~kTMXTileHorizontalFlag;
1361 flags |= kTMXTileHorizontalFlag;
1362 layer->setTileGID(GID, tileCoord, (TMXTileFlags)flags);
1372 std::string resources =
"TileMaps";
1373 std::string file = resources +
"/orthogonal-test1.tmx";
1375 auto fileUtils = FileUtils::getInstance();
1376 std::string str = fileUtils->getStringFromFile(fileUtils->fullPathForFilename(file.c_str()));
1378 auto map = TMXTiledMap::createWithXML(str ,resources.c_str());
1381 auto s = map->getContentSize();
1382 log(
"ContentSize: %f, %f", s.width,s.height);
1384 auto& children = map->getChildren();
1385 for(
const auto &node : children) {
1386 auto child =
static_cast<SpriteBatchNode*
>(node);
1387 child->getTexture()->setAntiAliasTexParameters();
1390 auto action = ScaleBy::create(2, 0.5f);
1391 map->runAction(action);
1396 return "TMX created from XML test";
1410 auto map = TMXTiledMap::create(
"TileMaps/xml-test.tmx");
1413 auto s = map->getContentSize();
1414 log(
"ContentSize: %f, %f", s.width,s.height);
1416 auto& children = map->getChildren();
1417 for(
const auto &node : children) {
1418 auto child =
static_cast<SpriteBatchNode*
>(node);
1419 child->getTexture()->setAntiAliasTexParameters();
1422 for(
int i=24;i<=26;i++){
1423 log(
"GID:%i, Properties:%s", i, map->getPropertiesForGID(i).asValueMap()[
"name"].asString().c_str());
1426 auto action = ScaleBy::create(2, 0.5f);
1427 map->runAction(action);
1432 return "you should see blue, green and yellow in console.";
1442 auto map = TMXTiledMap::create(
"TileMaps/orthogonal-test6.tmx");
1445 Size CC_UNUSED s1 = map->getContentSize();
1446 CCLOG(
"ContentSize: %f, %f", s1.width,s1.height);
1448 auto& children = map->getChildren();
1449 for(
const auto &child : children) {
1450 auto node =
static_cast<TMXLayer*
>(child);
1451 node->getTexture()->setAntiAliasTexParameters();
1454 map->setAnchorPoint(Vec2(0.0f, 0.0f));
1455 auto layer = map->getLayer(
"Tile Layer 1");
1456 layer->setTileGID(3, Vec2(2.0f,2.0f));
1461 return "TMX Bug 987";
1466 return "You should see an square";
1476 auto map = TMXTiledMap::create(
"TileMaps/iso-test-bug787.tmx");
1479 map->setScale(0.25f);
1484 return "TMX Bug 787";
1489 return "You should see a map";
1499 auto map = TMXTiledMap::create(
"TileMaps/test-object-layer.tmx");
1502 Size CC_UNUSED s = map->getContentSize();
1503 CCLOG(
"Contentsize: %f, %f", s.width, s.height);
1505 CCLOG(
"----> Iterating over all the group objects");
1507 auto drawNode = DrawNode::create();
1508 Color4F color(1.0, 1.0, 1.0, 1.0);
1509 auto group = map->getObjectGroup(
"Object Layer 1");
1510 auto& objects = group->getObjects();
1511 for (
auto& obj : objects)
1513 ValueMap& dict = obj.asValueMap();
1515 float x = dict[
"x"].asFloat();
1516 float y = dict[
"y"].asFloat();
1517 float width = dict[
"width"].asFloat();
1518 float height = dict[
"height"].asFloat();
1520 drawNode->drawLine(Vec2(x, y), Vec2(x + width, y), color);
1521 drawNode->drawLine(Vec2(x + width, y), Vec2(x + width, y + height), color);
1522 drawNode->drawLine(Vec2(x + width,y + height), Vec2(x,y + height), color);
1523 drawNode->drawLine(Vec2(x,y + height), Vec2(x,y), color);
1525 map->addChild(drawNode);
1530 return "TMX GID objects";
1535 return "Tiles are created from an object group";
1545 auto color = LayerColor::create( Color4B(64,64,64,255) );
1546 addChild(color, -1);
1548 auto map = TMXTiledMap::create(
"TileMaps/hexagonal-mini-odd-x.tmx");
1551 Size CC_UNUSED s = map->getContentSize();
1552 CCLOG(
"ContentSize: %f, %f", s.width,s.height);
1555 auto floor = map->getLayer(
"Ground");
1556 for (
auto x = 0; x < map->getMapSize().width; x++) {
1557 for (
auto y = 0; y < map->getMapSize().height; y++) {
1559 floor->getTileAt(p);
1566 return "TMX Hex Odd X";
1576 auto color = LayerColor::create( Color4B(64,64,64,255) );
1577 addChild(color, -1);
1579 auto map = TMXTiledMap::create(
"TileMaps/hexagonal-mini-odd-y.tmx");
1582 Size CC_UNUSED s = map->getContentSize();
1583 CCLOG(
"ContentSize: %f, %f", s.width,s.height);
1586 auto floor = map->getLayer(
"Ground");
1587 for (
auto x = 0; x < map->getMapSize().width; x++) {
1588 for (
auto y = 0; y < map->getMapSize().height; y++) {
1590 floor->getTileAt(p);
1597 return "TMX Hex Odd Y";
1607 auto color = LayerColor::create( Color4B(64,64,64,255) );
1608 addChild(color, -1);
1610 auto map = TMXTiledMap::create(
"TileMaps/hexagonal-mini-even-x.tmx");
1613 Size CC_UNUSED s = map->getContentSize();
1614 CCLOG(
"ContentSize: %f, %f", s.width,s.height);
1617 auto floor = map->getLayer(
"Ground");
1618 for (
auto x = 0; x < map->getMapSize().width; x++) {
1619 for (
auto y = 0; y < map->getMapSize().height; y++) {
1621 floor->getTileAt(p);
1628 return "TMX Hex Even X";
1638 auto color = LayerColor::create( Color4B(64,64,64,255) );
1639 addChild(color, -1);
1641 auto map = TMXTiledMap::create(
"TileMaps/hexagonal-mini-even-y.tmx");
1644 Size CC_UNUSED s = map->getContentSize();
1645 CCLOG(
"ContentSize: %f, %f", s.width,s.height);
1648 auto floor = map->getLayer(
"Ground");
1649 for (
auto x = 0; x < map->getMapSize().width; x++) {
1650 for (
auto y = 0; y < map->getMapSize().height; y++) {
1652 floor->getTileAt(p);
1659 return "TMX Hex Even Y";
1669 auto color = LayerColor::create( Color4B(64,64,64,255) );
1670 addChild(color, -1);
1672 auto map = TMXTiledMap::create(
"TileMaps/hexa-axis-x.tmx");
1675 Size CC_UNUSED s = map->getContentSize();
1676 CCLOG(
"ContentSize: %f, %f", s.width,s.height);
1681 return "The map should be same with in Tiled Editor";
1691 auto color = LayerColor::create( Color4B(64,64,64,255) );
1692 addChild(color, -1);
1694 auto map = TMXTiledMap::create(
"TileMaps/issue16105.tmx");
1697 Size CC_UNUSED s = map->getContentSize();
1698 CCLOG(
"ContentSize: %f, %f", s.width,s.height);
1703 return "Github Issue #16105";
1713 auto color = LayerColor::create( Color4B(64,64,64,255) );
1714 addChild(color, -1);
1716 auto map = TMXTiledMap::create(
"TileMaps/issue_16512.tmx");
1719 Size CC_UNUSED s = map->getContentSize();
1720 CCLOG(
"ContentSize: %f, %f", s.width,s.height);
1722 auto floor = map->getLayer(
"Floor");
1723 for (
auto x = 0; x < map->getMapSize().width; x++) {
1724 for (
auto y = 0; y < map->getMapSize().height; y++) {
1726 floor->getTileAt(p);
1733 return "Github Issue #16512. Should not crash";
#define ADD_TEST_CASE(__className__)
virtual std::string title() const override
virtual std::string title() const override
virtual std::string title() const override
virtual std::string subtitle() const override
virtual std::string title() const override
virtual std::string subtitle() const override
virtual std::string subtitle() const override
virtual std::string title() const override
virtual std::string title() const override
virtual std::string title() const override
virtual std::string title() const override
virtual std::string title() const override
virtual std::string title() const override
virtual std::string title() const override
virtual std::string title() const override
virtual std::string subtitle() const override
virtual std::string subtitle() const override
virtual std::string title() const override
virtual std::string title() const override
virtual std::string title() const override
virtual std::string title() const override
virtual void onExit() override
virtual std::string title() const override
virtual void onEnter() override
virtual std::string subtitle() const override
void repositionSprite(float dt)
cocos2d::Sprite * _tamara
virtual std::string subtitle() const override
virtual std::string title() const override
void repositionSprite(float dt)
cocos2d::Sprite * _tamara
virtual void onExit() override
virtual std::string title() const override
virtual std::string subtitle() const override
TMXOrthoFlipRunTimeTest()
virtual std::string title() const override
virtual std::string title() const override
virtual std::string title() const override
virtual std::string subtitle() const override
virtual std::string subtitle() const override
virtual std::string title() const override
virtual std::string title() const override
virtual std::string title() const override
void removeSprite(float dt)
virtual std::string title() const override
virtual void onExit() override
virtual std::string title() const override
virtual void onEnter() override
virtual void onExit() override
cocos2d::Sprite * _tamara
virtual void onEnter() override
virtual std::string title() const override
void repositionSprite(float dt)
virtual std::string subtitle() const override
virtual ~TMXOrthoZorder()
virtual std::string title() const override
void repositionSprite(float dt)
virtual std::string subtitle() const override
cocos2d::Sprite * _tamara
void removeSprite(Node *sender)
void removeTiles(float dt)
void repaintWithGID(float dt)
virtual std::string title() const override
virtual std::string title() const override
virtual std::string subtitle() const override
virtual void onEnter() override
virtual std::string title() const override
virtual void onExit() override
virtual std::string title() const override
virtual std::string subtitle() const override
virtual std::string title() const override
virtual std::string title() const override
virtual void onEnter() override
void onTouchesMoved(const std::vector< cocos2d::Touch * > &touches, cocos2d::Event *event)
virtual void onExit() override
virtual std::string title() const override
virtual std::string subtitle() const override
virtual std::string title() const override
virtual std::string title() const override
static const char s_TilesPng[]
static const char s_LevelMapTga[]
static const char s_pathSister1[]