本文整理汇总了C++中Armature::getBoundingBox方法的典型用法代码示例。如果您正苦于以下问题:C++ Armature::getBoundingBox方法的具体用法?C++ Armature::getBoundingBox怎么用?C++ Armature::getBoundingBox使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Armature
的用法示例。
在下文中一共展示了Armature::getBoundingBox方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
//.........这里部分代码省略.........
end_fight_cancel_button->setPosition(Vec2(140, 30));
end_fight_cancel_button->addTouchEventListener([=](Ref* pSender, Widget::TouchEventType type){
end_fight_dialog_bg->setVisible(false);
});
end_fight_dialog_bg->setVisible(false);
end_fight_button->addTouchEventListener([=](Ref* pSender, Widget::TouchEventType type){
if (type == Widget::TouchEventType::ENDED){
end_fight_dialog_bg->setVisible(true);
}
});
// ⑤创建事件监听器
auto gameListener = EventListenerTouchOneByOne::create();
// 响应触摸事件函数
gameListener->onTouchBegan = [](Touch* touch, Event* event){return true; };
gameListener->onTouchEnded = [=](Touch *touch, Event *event){
// OpenGL坐标
Vec2 touchLocation = touch->getLocation();
// 将触摸点坐标转换成相对的Node坐标
Vec2 nodeLocation = this->convertToNodeSpace(touchLocation);
// 玩家镜像反转
if (_player->getPosition().x > nodeLocation.x) {
if (_player->isFlippedX() == true){
_player->setFlippedX(false);
}
}
else{
if (_player->isFlippedX() == false)
_player->setFlippedX(true);
}
// 用玩家位置作为起点,触摸点作为终点,转换为网格坐标,在地图上查找最佳到达路径
Vec2 from = tileCoordForPosition(_player->getPosition());
Vec2 to = tileCoordForPosition(nodeLocation);
// 如果终点是不可通过(即有障碍物)的位置,则直接return
int tileGid = _collidable->getTileGIDAt(to);
if (tileGid) {
// 使用GID来查找指定tile的属性,返回一个Value
Value properties = _tileMap->getPropertiesForGID(tileGid);
// 返回的Value实际是一个ValueMap
ValueMap map = properties.asValueMap();
// 查找ValueMap,判断是否有”可碰撞的“物体,如果有,直接返回
std::string value = map.at("collidable").asString();
if (value.compare("true") == 0) {
return;
}
}
/**************玩家精灵移动到指定位置************************/
// 在玩家精灵移动过程中,如果用户在此触摸屏幕移动玩家时,如果精灵没有运行动作,直接执行移动动作
if (_player->getNumberOfRunningActions() == 0) {
this->playerMover(nodeLocation);
}
else
{
//如果精灵正在运行动作,先停止精灵动作和层动作,再执行移动动作
_player->stopAllActions();
this->stopAllActions();
this->playerMover(nodeLocation);
}
// 接触传送门, 如果boss被杀死, 则传送回主场景.
if (_player->getBoundingBox().intersectsRect(armature->getBoundingBox())){
if (monster_1->isVisible()==false){
_player->setExp(_player->getExp() + 200);
_player->setGold(_player->getGold() + 1000);
XmlTools::writePlayerData(_player);
const string player_task = FileUtils::getInstance()->fullPathForFilename("data/kill_count.xml");
ssize_t player_taskFile_size;
char* pPlayerTaskContent = (char*)FileUtils::getInstance()->getFileData(player_task, "r", &player_taskFile_size);
TiXmlDocument* player_task_el = new TiXmlDocument();
player_task_el->Parse(pPlayerTaskContent, 0, TIXML_ENCODING_UTF8);
TiXmlElement* rootElement = player_task_el->RootElement();//Root
TiXmlElement* player_kill_count_1 = rootElement->FirstChildElement();
string accept = player_kill_count_1->GetText();
TiXmlElement* player_kill_count_2 = player_kill_count_1->NextSiblingElement();
stringstream ss;
string kill_count = player_kill_count_2->GetText();
int kill_count_int;
ss << kill_count;
ss >> kill_count_int;
if (accept=="true"){
kill_count_int += 1;
player_kill_count_2->Clear();
string kill_count_str;
stringstream ss;
ss << kill_count_int;
ss >> kill_count_str;
TiXmlText* kill_count_text = new TiXmlText(kill_count_str.c_str());
player_kill_count_2->LinkEndChild(kill_count_text);
player_task_el->SaveFile(player_task.c_str());
}
auto transform_to = TransitionSplitCols::create(2.0f, Game::createScene());
Director::getInstance()->pushScene(transform_to);
}