本文整理汇总了C++中Tower::setTag方法的典型用法代码示例。如果您正苦于以下问题:C++ Tower::setTag方法的具体用法?C++ Tower::setTag怎么用?C++ Tower::setTag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tower
的用法示例。
在下文中一共展示了Tower::setTag方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addTower
void StartScene::addTower(Point pos, Tower::TowerType towerType)
{
DataModel *m = DataModel::getModel();
Tower *target = NULL ;
Point towerLoc = this->tileCoordForPosition(pos);
int tileGid = this->_background->tileGIDAt(towerLoc);
Value props = this->_tileMap->propertiesForGID(tileGid);
ValueMap map = props.asValueMap();
int type_int = map.at("buildable").asInt();
target = Tower::createWithType(towerType);
if (target->price>m->currentMoney) {
MessageBox("no enough money!","");
return;
}
if (1 == type_int)
{
// std::string targetPos = "pos.x = "+std::to_string(towerLoc.x)+" pos.y = "+std::to_string(towerLoc.y);
// log(targetPos.c_str());
bool buildable = true;
for (auto point = m->buildedPoints.equal_range(towerLoc.x); point.first!=point.second; ++point.first) {
if (towerLoc.y==point.first->second) {
buildable = false;
break;
}
}
if (buildable) {
m->buildedPoints.insert(std::make_pair(towerLoc.x, towerLoc.y));
target->setPosition(ccp((towerLoc.x * 32) + 16, this->_tileMap->getContentSize().height - (towerLoc.y * 32) - 16));
this->addChild(target,1);
target->setTag(1);
m->currentMoney -= target->price;
money->setText(to_string(m->currentMoney));
m->towers.pushBack(target);
}
}
else
{
log("Tile Not Buildable");
}
}