void StartScene::addWayPoint() { DataModel *m = DataModel::getModel(); auto objects = this->_tileMap->objectGroupNamed("Objects"); WayPoint *wp = NULL; std::string stringWithFormat = "Waypoint"; int wayPointCounter = 0; ValueMap wayPoint; wayPoint = objects->objectNamed(stringWithFormat + to_string(wayPointCounter)); while (wayPoint.begin() != wayPoint.end()) { int x = wayPoint.at("x").asInt(); int y = wayPoint.at("y").asInt(); wp = WayPoint::create(); wp->setPosition(ccp(x, y)); m->waypoints.pushBack(wp); wayPointCounter++; wayPoint = objects->objectNamed(stringWithFormat + to_string(wayPointCounter)); } wp =NULL; }
void HelloWorld::addWaypoint() { DataModel *m = DataModel::getModel(); CCTMXObjectGroup *objects =_tileMap->objectGroupNamed("Objects"); WayPoint *wp = NULL; int spawnPointCounter = 0; CCDictionary *spawnPoint; while ((spawnPoint =objects ->objectNamed(CCString::createWithFormat("Waypoint%d", spawnPointCounter)->getCString()))) { int x = spawnPoint->valueForKey("x")->intValue(); int y = spawnPoint->valueForKey("y")->intValue(); wp =(WayPoint *)WayPoint::create(); wp->setPosition(ccp(x, y)); m->getWaypoints()->addObject(wp); spawnPointCounter++; } // NSAssert([m->getWaypoints()->count()] > 0, @"Waypoint objects missing"); wp = NULL; }