Tile Map cocos2d-x c++
Cocos2d-x v3-
cloudmobileLikes 0Problem Description
Hi, I new to cocos2d-x , I would like to know how to spawn a player (objects) in Tile Map(isometric z-order). I have found some tutorial online https://www.raywenderlich.com/39113/cocos2d-x-tile-map-tutorial-part-1, the codes are very deprecated.
Any help is appreciated.
Thanks in advance
auto map = TMXTiledMap::create("TileGameResources/iso4.tmx");
//map->setPosition(Point((visibleSize.width) + origin.x, (visibleSize.height) + origin.y));
map->setPosition(Vec2()+origin);
float rX1 = visibleSize.width / map->getContentSize().width;
float rY1 = visibleSize.height / map->getContentSize().height;
map->setScaleX(rX1);
map->setScaleY(rY1);
this->addChild(map, 1, 99); // with a tag of '99'
TMXObjectGroup *objectGroup = map->objectGroupNamed("Objects");
if(objectGroup == NULL){
CCLog("tile map has no objects object layer");
return false;
}
map *spawnPoint = objectGroup->objectNamed("SpawnPoint");
int x = ((CCString)*spawnPoint->valueForKey("x")).intValue();
int y = ((CCString)*spawnPoint->valueForKey("y")).intValue();
_player = new Sprite();
_player->initWithFile("Player.png");
_player->setPosition(ccp(x,y));
this->addChild(_player);
-
cloudmobileLikes 0
I did, it just gives me information on how to load the map, no information on how to spawn objects, handle collision detection
Login to reply