本文整理汇总了C++中Armature::getAnimation方法的典型用法代码示例。如果您正苦于以下问题:C++ Armature::getAnimation方法的具体用法?C++ Armature::getAnimation怎么用?C++ Armature::getAnimation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Armature
的用法示例。
在下文中一共展示了Armature::getAnimation方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: defaultPlay
void EffectComponentTest::defaultPlay()
{
ComRender *render = static_cast<ComRender*>(_rootNode->getChildByTag(10015)->getComponent("CCArmature"));
Armature *pAr = static_cast<Armature*>(render->getNode());
pAr->getAnimation()->setMovementEventCallFunc(CC_CALLBACK_0(EffectComponentTest::animationEvent, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
}
示例2: benginRunning
void CHorseRunning::benginRunning()
{
Size visibleSize = Director::getInstance()->getVisibleSize();
//Point origin = Director::getInstance()->getVisibleOrigin();
ArmatureDataManager::getInstance()->addArmatureFileInfo("putongma001.ExportJson");
m_pArmature = Armature::create("putongma001");
m_pArmature->getAnimation()->play("Animation1");
m_pArmature->setScale(0.5);
m_pArmature->getAnimation()->setSpeedScale(1);
m_pArmature->setZOrder(1000 - 345);
m_pArmature->setPosition(Point(visibleSize.width/2 ,345));
addChild(m_pArmature);
m_nType = 1;
for (int i = 1; i<10; i++) {
ArmatureDataManager::getInstance()->addArmatureFileInfo(StringUtils::format("guanzhong_00%d.ExportJson",i));
cocostudio::Armature* armature = Armature::create(StringUtils::format("guanzhong_00%d",i));
armature->getAnimation()->play("Animation1");
// armature->setScale(0.5);
armature->getAnimation()->setSpeedScale(1);
armature->setPosition(Point(visibleSize.width*i/18+ visibleSize.width/6, visibleSize.height*3/4));
addChild(armature);
}
for(int i = 10;i<21;i++)
{
if(i==17)
{
ArmatureDataManager::getInstance()->addArmatureFileInfo("guanzhong_17.ExportJson");
cocostudio::Armature* armature = Armature::create("guanzhong_17");
armature->getAnimation()->play("Animation1");
// armature->setScale(0.5);
armature->getAnimation()->setSpeedScale(1);
armature->setPosition(Point(visibleSize.width*(i-9)/18 + visibleSize.width/6, visibleSize.height*3/4 + visibleSize.width/18));
addChild(armature);
}
else
{
ArmatureDataManager::getInstance()->addArmatureFileInfo(StringUtils::format("guanzhong_0%d.ExportJson",i));
cocostudio::Armature* armature = Armature::create(StringUtils::format("guanzhong_0%d",i));
armature->getAnimation()->play("Animation1");
// armature->setScale(0.5);
armature->getAnimation()->setSpeedScale(1);
armature->setPosition(Point(visibleSize.width*(i-9)/18+ visibleSize.width/6, visibleSize.height*3/4 + visibleSize.width/18));
addChild(armature);
}
}
ArmatureDataManager::getInstance()->addArmatureFileInfo("sheyingshi001.ExportJson");
m_pDirector = Armature::create("sheyingshi001");
m_pDirector->getAnimation()->play("Animation1");
m_pDirector->getAnimation()->setSpeedScale(1);
m_pDirector->setPosition(Point(visibleSize.width/2 + 100,0));
m_pDirector->setZOrder(1000);
addChild(m_pDirector);
ArmatureDataManager::getInstance()->addArmatureFileInfo("baozouzu_001.ExportJson");
Armature* armatureAi = Armature::create("baozouzu_001");
armatureAi->getAnimation()->play("Animation1");
armatureAi->getAnimation()->setSpeedScale(1);
armatureAi->setScale(0.5);
armatureAi->setPosition(Point(visibleSize.width/2,255));
armatureAi->setZOrder(1000 - 255);
addChild(armatureAi);
m_VecArmatureAi.pushBack(armatureAi);
ArmatureDataManager::getInstance()->addArmatureFileInfo("baozouzu_002.ExportJson");
Armature* armatureAi2 = Armature::create("baozouzu_002");
armatureAi2->getAnimation()->play("Animation1");
armatureAi2->getAnimation()->setSpeedScale(1);
armatureAi2->setScale(0.5);
armatureAi2->setPosition(Point(visibleSize.width*3/4,185));
armatureAi2->setZOrder(1000 - 185);
addChild(armatureAi2);
m_VecArmatureAi.pushBack(armatureAi2);
ArmatureDataManager::getInstance()->addArmatureFileInfo("baozouzu_002.ExportJson");
Armature* armatureAi3 = Armature::create("baozouzu_002");
armatureAi3->getAnimation()->play("Animation1");
armatureAi3->getAnimation()->setSpeedScale(1);
armatureAi3->setScale(0.5);
armatureAi3->setPosition(Point(visibleSize.width*3/4,125));
armatureAi3->setZOrder(1000 - 125);
addChild(armatureAi3);
m_VecArmatureAi.pushBack(armatureAi3);
//m_pDirector->getAnimation()->setFrameEventCallFunc(this,frameEvent_selector(CHorseRunning::onFrameEvent));
m_pArmature->runAction(Sequence::create(RotateBy::create(2,-360), NULL));
}
示例3: init
bool FiledScene::init(){
if (!Layer::init())
return false;
_isGameOver = false;
auto visibleSize = Director::getInstance()->getVisibleSize();
_screenWidth = visibleSize.width;
_screenHeight = visibleSize.height;
_tileMap = TMXTiledMap::create("field_map.tmx");
_tileMap->setAnchorPoint(Vec2::ANCHOR_MIDDLE);
_tileMap->setPosition(Vec2(visibleSize.width / 2, visibleSize.height / 2));
// ②获取障碍层,并设置障碍层为不可见
_collidable = _tileMap->getLayer("collidable");
_collidable->setVisible(false);
/********③初始化读取地图所有网格,并确定网格对象是否是障碍物,将信息保存到网格二维数组**************/
for (int i = 0; i < _tileMap->getMapSize().width; i++) {
// 内部网格集合([x,0]-[x-20]),存储网格
Vector<Grid*> inner;
for (int j = 0; j < _tileMap->getMapSize().height; j++) {
// 设置网格对象的x轴和y轴以及是否可通过变量值
Grid *o = Grid::create(i, j);
// 将网格加入到集合
inner.pushBack(o);
}
// 将内部集合加入到网格集合
_gridVector.push_back(inner);
}
// 循环保存根据每个网格的x轴和y轴查找对应的地图的GID,判断是否可通过
for (int i = 0; i < _gridVector.size(); i++) {
Vector<Grid*> inner = _gridVector.at(i);
// 循环内部网格集合
for (int j = 0; j < inner.size(); j++) {
// 获取每一个网格对象
Grid *grid = inner.at(j);
// 获取每一个网格对象对应的的坐标
Vec2 tileCoord = Vec2(grid->getX(), grid->getY());
// 使用TMXLayer类的tileGIDAt函数获取TileMap坐标系里的“全局唯一标识”GID
int tileGid = _collidable->getTileGIDAt(tileCoord);
if (tileGid) {
// 使用GID来查找指定tile的属性,返回一个Value
Value properties = _tileMap->getPropertiesForGID(tileGid);
// 返回的Value实际是一个ValueMap
ValueMap map = properties.asValueMap();
// 查找ValueMap,判断是否有”可碰撞的“物体,如果有,设置网格对象的isPass变量为false
std::string value = map.at("collidable").asString();
if (value.compare("true") == 0) {
grid->setPass(false);
}
}
}
}
// 人物出场特效
auto effects_player_out = Sprite::create("effects/effects_player_out/effects_player_out_11.png");
effects_player_out->setPosition(Vec2(visibleSize.width*0.3,visibleSize.height*0.3));
this->addChild(effects_player_out, 1);
auto player_out_animate = getAnimateByName("effects/effects_player_out/effects_player_out_", 0.1f, 11);
auto delay1 = DelayTime::create(1.5f);
auto fadeOut = FadeOut::create(0.2f);
auto sequence = Sequence::create(delay1, player_out_animate, fadeOut, nullptr);
effects_player_out->runAction(sequence);
_player = SpriteBase::create("player/player_sword/player_sword_stand.png");
this->addChild(_player, 1);
_player->setPosition(Vec2(visibleSize.width*0.3, visibleSize.height*0.3));
this->addChild(_tileMap,0);
_player->setFlippedX(true);
XmlTools::readPlayerData(_player);
/// 传送门
ArmatureDataManager::getInstance()->addArmatureFileInfo("/buildings/gate/AnimationStart0.png", "/buildings/gate/AnimationStart0.plist", "/buildings/gate/AnimationStart.ExportJson");
Armature *armature = Armature::create("AnimationStart");
armature->getAnimation()->play("Start");
this->addChild(armature);
armature->setScale(0.3);
armature->setPosition(Vec2(visibleSize.width*0.9, visibleSize.height*0.7));
auto gate_effect = ParticleSystemQuad::create("effects/gate_effect.plist");
this->addChild(gate_effect);
gate_effect->setScale(0.3);
gate_effect->setPosition(Vec2(visibleSize.width*0.9, visibleSize.height*0.75));
gate_effect->setPositionType(kCCPositionTypeRelative);
// 结束战斗按钮
auto end_fight_button = Button::create("ui/end_fight.png");
end_fight_button->setPosition(Vec2(visibleSize.width*0.95, visibleSize.height*0.97));
end_fight_button->setScale(0.5f);
this->addChild(end_fight_button, 0);
//结束战斗对话框
auto end_fight_dialog_bg = Sprite::create("ui/end_fight_dialog_bg.png");
end_fight_dialog_bg->setAnchorPoint(Vec2::ANCHOR_MIDDLE);
end_fight_dialog_bg->setPosition(Vec2(visibleSize.width / 2, visibleSize.height / 2));
this->addChild(end_fight_dialog_bg, 3);
// 确定结束战斗按钮
auto end_fight_sub_button = Button::create("ui/end_fight_sub_button.png");
end_fight_dialog_bg->addChild(end_fight_sub_button);
end_fight_sub_button->setAnchorPoint(Vec2::ZERO);
end_fight_sub_button->setPosition(Vec2(20, 30));
//.........这里部分代码省略.........
示例4: buildArmature
//.........这里部分代码省略.........
{
armature->addBone(bone);
}
}
ArmatureData* animationArmatureData = 0;
SkinData *skinDataCopy = 0;
if(!animationName.empty() && animationName != armatureName)
{
//ArmatureData* animationArmatureData = data->getArmatureData(animationName);
// Get the default animation
//if(!animationArmatureData)
//{
// for (skeletonName in _dataDic)
// {
// data = _dataDic[skeletonName];
// animationArmatureData = data->getArmatureData(animationName);
// if(animationArmatureData)
// {
// break;
// }
// }
//}
ArmatureData* armatureDataCopy = data->getArmatureData(animationName);
if(armatureDataCopy)
{
skinDataCopy = armatureDataCopy->getSkinData("");
}
}
if(animationArmatureData)
{
armature->getAnimation()->setAnimationDataList(animationArmatureData->animationDataList);
}
else
{
armature->getAnimation()->setAnimationDataList(armatureData->animationDataList);
}
SkinData* skinData = armatureData->getSkinData(skinName);
if(!skinData)
{
return nullptr;
//throw new ArgumentError();
}
Slot* slot;
DisplayData* displayData;
Armature* childArmature;
size_t i;
//var helpArray:Array = [];
for(size_t j = 0 ; j < skinData->slotDataList.size() ; j ++)
{
SlotData* slotData = skinData->slotDataList[j];
bone = armature->getBone(slotData->parent);
if(!bone)
{
continue;
}
slot = generateSlot();
slot->name = slotData->name;
slot->setBlendMode(slotData->blendMode);
slot->_originZOrder = slotData->zOrder;
slot->_dislayDataList = slotData->displayDataList;
示例5: init
// on "init" you need to initialize your instance
bool HelloWorld::init()
{
bool bRet = false;
do
{
//////////////////////////////////////////////////////////////////////////
// super init first
//////////////////////////////////////////////////////////////////////////
CC_BREAK_IF(! CCLayerColor::initWithColor(ccc4(200, 200, 200, 255)));
// CC_BREAK_IF(! CCLayerColor::initWithColor(ccc4(0, 0, 0, 255)));
CCSize size = CCDirector::sharedDirector()->getWinSize();
weaponIndex = 0;
BatchNodeManager::sharedBatchNodeManager()->initWithLayer(this, "TEST_ARMATURE");
ArmatureDataManager::sharedArmatureDataManager()->addArmatureFileInfo("Zombie_f/Zombie", "", "zombie.png", "zombie.plist", "zombie.xml");
ArmatureDataManager::sharedArmatureDataManager()->addArmatureFileInfo("Knight_f/Knight", "", "knight.png", "knight.plist", "knight.xml");
ArmatureDataManager::sharedArmatureDataManager()->addArmatureFileInfo("cyborg", "", "cyborg.png", "cyborg.plist", "cyborg.xml");
ArmatureDataManager::sharedArmatureDataManager()->addArmatureFileInfo("Zombie_ladder", "", "zombie_ladder.png", "zombie_ladder.plist", "zombie_ladder.xml");
ArmatureDataManager::sharedArmatureDataManager()->addArmatureFileInfo("bird", "", "bird.png", "bird.plist", "bird.xml");
ArmatureDataManager::sharedArmatureDataManager()->addArmatureFileInfo("weapon", "", "weapon.png", "weapon.plist", "weapon.xml");
armatures = new CCArray();
Armature *armature = NULL;
//! use BATCHNODE_VERTEXZ you can change display in different batchnode
BatchNodeManager::sharedBatchNodeManager()->getBatchNode("weapon.png")->setRenderType(BATCHNODE_VERTEXZ);
armature = Armature::create("Knight_f/Knight");
armature->getAnimation()->play("run");
armature->setPosition(size.width/2 + 50, size.height/2);
armatures->addObject(armature);
armature = Armature::create("cyborg");
armature->getAnimation()->play("run");
armature->setPosition(size.width/2 + 130, size.height/2);
armature->getAnimation()->MovementEventSignal.connect(this, &HelloWorld::onMovementEvent);
armature->setZOrder(2);
armatures->addObject(armature);
//
armature = Armature::create("Zombie_f/Zombie");
armature->getAnimation()->play("run");
armature->setPosition(size.width/2 + 100, size.height/2);
armature->setZOrder(1);
armatures->addObject(armature);
// armature = Armature::create("Knight_f/Knight");
// armature->getAnimation()->play("run");
// armature->setPosition(size.width/2 - 150, size.height/2);
//
// SpriteDisplayData *param = SpriteDisplayData::create();
// param->setParam("weapon_f-sword2.png");
//
// armature->getBone("weapon")->addDisplay(param, 0);
// armature->setRenderType(BATCHNODE_VERTEXZ);
// armatures->addObject(armature);
//
armature = Armature::create("Zombie_ladder");
armature->getAnimation()->play("anim_placeladder", 0, 50, 1, TWEEN_EASING_MAX);
armature->getAnimation()->setAnimationScale(3);
armature->setPosition(size.width/2 - 230, size.height/2 -100);
armatures->addObject(armature);
armature = Armature::create("bird");
armature->getAnimation()->play("changeColor");
armature->setPosition(size.width/2 - 230, size.height/2 + 100);
armatures->addObject(armature);
// for (int i = 0; i<600; i++)
// {
// Armature *armature = Armature::create("Knight_f/Knight");
// armature->getAnimation()->play("run");
// armature->setPosition(30 + (i%20)*(size.width/21), 30 + (i/20)*20);
// armatures->addObject(armature);
// }
scheduleUpdate();
bRet = true;
} while (0);
return bRet;
}
示例6: playAni
void EventBoard::playAni()
{
Armature *armature = (Armature*)_UINode->getChildByTag(888);
armature->setVisible(true);
armature->getAnimation()->playWithIndex(0, -1, 0);//from the first frame, no loop
}
示例7: buildArmature
Armature* BaseFactory::buildArmature(const std::string &armatureName, const std::string &skinName, const std::string &animationName, const std::string &dragonBonesName, const std::string &textureAtlasName) const
{
DragonBonesData *dragonBonesData = nullptr;
ArmatureData *armatureData = nullptr;
ArmatureData *animationArmatureData = nullptr;
SkinData *skinData = nullptr;
SkinData *skinDataCopy = nullptr;
if (!dragonBonesName.empty())
{
auto iterator = _dragonBonesDataMap.find(dragonBonesName);
if (iterator != _dragonBonesDataMap.end())
{
dragonBonesData = iterator->second;
armatureData = dragonBonesData->getArmatureData(armatureName);
_currentDragonBonesDataName = dragonBonesName;
_currentTextureAtlasName = textureAtlasName.empty() ? _currentDragonBonesDataName : textureAtlasName;
}
}
if (!armatureData)
{
AutoSearchType searchType = (dragonBonesName.empty() ? AutoSearchType::AST_ALL : (autoSearchDragonBonesData ? AutoSearchType::AST_AUTO : AutoSearchType::AST_NONE));
if (searchType != AutoSearchType::AST_NONE)
{
for (auto iterator = _dragonBonesDataMap.begin(); iterator != _dragonBonesDataMap.end(); ++iterator)
{
dragonBonesData = iterator->second;
if (searchType == AutoSearchType::AST_ALL || dragonBonesData->autoSearch)
{
armatureData = dragonBonesData->getArmatureData(armatureName);
if (armatureData)
{
_currentDragonBonesDataName = iterator->first;
_currentTextureAtlasName = _currentDragonBonesDataName;
break;
}
}
}
}
}
if (!armatureData)
{
return nullptr;
}
if (!animationName.empty() && animationName != armatureName)
{
animationArmatureData = dragonBonesData->getArmatureData(animationName);
if (!animationArmatureData)
{
for (auto iterator = _dragonBonesDataMap.begin(); iterator != _dragonBonesDataMap.end(); ++iterator)
{
dragonBonesData = iterator->second;
animationArmatureData = dragonBonesData->getArmatureData(animationName);
if (animationArmatureData)
{
break;
}
}
}
if (animationArmatureData)
{
skinDataCopy = animationArmatureData->getSkinData("");
}
}
skinData = armatureData->getSkinData(skinName);
Armature *armature = generateArmature(armatureData);
armature->name = armatureName;
if (animationArmatureData)
{
armature->getAnimation()->setAnimationDataList(animationArmatureData->animationDataList);
}
else
{
armature->getAnimation()->setAnimationDataList(armatureData->animationDataList);
}
//
buildBones(armature, armatureData);
//
if (skinData)
{
buildSlots(armature, armatureData, skinData, skinDataCopy);
}
// update armature pose
armature->getAnimation()->play();
armature->advanceTime(0);
//.........这里部分代码省略.........
示例8: init
// on "init" you need to initialize your instance
bool HelloWorld::init()
{
bool bRet = false;
do
{
//////////////////////////////////////////////////////////////////////////
// super init first
//////////////////////////////////////////////////////////////////////////
CC_BREAK_IF(! CCLayerColor::initWithColor(ccc4(200, 200, 200, 255)));
// CC_BREAK_IF(! CCLayerColor::initWithColor(ccc4(0, 0, 0, 255)));
CCSize size = CCDirector::sharedDirector()->getWinSize();
weaponIndex = 0;
BatchNodeManager::sharedBatchNodeManager()->initWithLayer(this, "TEST_ARMATURE");
ArmatureDataManager::sharedArmatureDataManager()->addArmatureFileInfo("Zombie_f/Zombie", "", "zombie.png", "zombie.plist", "zombie.xml");
ArmatureDataManager::sharedArmatureDataManager()->addArmatureFileInfo("Knight_f/Knight", "", "knight.png", "knight.plist", "knight.xml");
ArmatureDataManager::sharedArmatureDataManager()->addArmatureFileInfo("cyborg", "", "cyborg.png", "cyborg.plist", "cyborg.xml");
// if the png, plist, xml is same, you can use param _useExistFileInfo
ArmatureDataManager::sharedArmatureDataManager()->addArmatureFileInfo("armInside", "cyborg", "", "", "");
ArmatureDataManager::sharedArmatureDataManager()->addArmatureFileInfo("armOutside", "cyborg", "", "", "");
ArmatureDataManager::sharedArmatureDataManager()->addArmatureFileInfo("circle_in_circle_stage3", "", "loading.png", "loading.plist", "loading.xml");
ArmatureDataManager::sharedArmatureDataManager()->addArmatureFileInfo("Cattail", "", "Cattail.png", "Cattail.plist", "Cattail.xml");
ArmatureDataManager::sharedArmatureDataManager()->addArmatureFileInfo("Zombie_ladder", "", "zombie_ladder.png", "zombie_ladder.plist", "zombie_ladder.xml");
ArmatureDataManager::sharedArmatureDataManager()->addArmatureFileInfo("Zombie_ladder", "", "zombie_ladder.png", "zombie_ladder.plist", "zombie_ladder.xml");
ArmatureDataManager::sharedArmatureDataManager()->addArmatureFileInfo("bird", "", "bird.png", "bird.plist", "bird.xml");
ArmatureDataManager::sharedArmatureDataManager()->addArmatureFileInfo("weapon", "", "weapon.png", "weapon.plist", "weapon.xml");
armatures = new CCArray();
Armature *armature = NULL;
//! use BATCHNODE_VERTEXZ you can change display in different batchnode
BatchNodeManager::sharedBatchNodeManager()->getBatchNode("knight.png")->setRenderType(BATCHNODE_VERTEXZ);
BatchNodeManager::sharedBatchNodeManager()->getBatchNode("cyborg.png")->setRenderType(BATCHNODE_VERTEXZ);
BatchNodeManager::sharedBatchNodeManager()->getBatchNode("zombie.png")->setRenderType(BATCHNODE_VERTEXZ);
armature = Armature::create("cyborg");
armature->getAnimation()->play("run");
armature->getDisplay()->setPosition(ccp(size.width/2 + 130, size.height/2));
armature->setZOrder(2);
armature->setAnimationCallback(this);
armatures->addObject(armature);
armature = Armature::create("Zombie_f/Zombie");
armature->getAnimation()->play("run");
armature->getDisplay()->setPosition(ccp(size.width/2 + 100, size.height/2));
armature->setZOrder(1);
armatures->addObject(armature);
armature = Armature::create("Knight_f/Knight");
armature->getAnimation()->play("run");
armature->getDisplay()->setPosition(ccp(size.width/2 + 50, size.height/2));
armatures->addObject(armature);
armature = Armature::create("Knight_f/Knight");
armature->getAnimation()->play("run");
armature->getDisplay()->setPosition(ccp(size.width/2 - 150, size.height/2));
armature->getBone("weapon")->addSpriteDisplay("weapon_f-sword2.png", "weapon.png", 0);
armatures->addObject(armature);
// armature = Armature::create("circle_in_circle_stage3");
// armature->getAnimation()->play("loading");
// armature->getDisplay()->setPosition(ccp(size.width/2, size.height/2));
// armatures->addObject(armature);
armature = Armature::create("Cattail");
armature->getAnimation()->play("anim_shooting");
armature->getDisplay()->setPosition(ccp(size.width/2 + 50, size.height/2 - 100));
armatures->addObject(armature);
armature = Armature::create("Zombie_ladder");
armature->getAnimation()->play("anim_placeladder", 0, 50, 1, TWEEN_EASING_MAX);
armature->getAnimation()->setAnimationScale(3);
armature->getDisplay()->setPosition(ccp(size.width/2 - 230, size.height/2 -100));
armatures->addObject(armature);
armature = Armature::create("bird");
armature->getAnimation()->play("changeColor");
armature->getDisplay()->setPosition(ccp(size.width/2 - 230, size.height/2 + 100));
armatures->addObject(armature);
// for (int i = 0; i<500; i++)
// {
// Armature *armature = Armature::create("Knight_f/Knight");
//.........这里部分代码省略.........
示例9: update
void HelloWorld::update(float delta)
{
if(m_bStart)
{
ComRender *pHeroRender = (ComRender*)(m_pGameScene->getChildByTag(10005)->getComponent("CCArmature"));
Armature *pHero = (Armature*)(pHeroRender->getNode());
pHero->getParent()->setPositionX(pHero->getParent()->getPositionX() + m_fSpeed);
ComRender *pEnemyRender = (ComRender*)(m_pGameScene->getChildByTag(10006)->getComponent("CCArmature"));
Armature *pEnemy = (Armature*)(pEnemyRender->getNode());
/* for 3.0 */
float distance = Point(pHero->getParent()->getPositionX(), 0).getDistance(Point(pEnemy->getParent()->getPositionX(), 0));
if (distance < m_fAttackDis)
{
pHero->getAnimation()->play("attack");
pHero->getAnimation()->setMovementEventCallFunc(this,
movementEvent_selector(HelloWorld::animationEvent));
m_bStart = false;
}
// before
/*
if(ccpDistance(ccp(pHero->getParent()->getPositionX(), 0), ccp(pEnemy->getParent()->getPositionX(), 0)) < m_fAttackDis)
{
pHero->getAnimation()->play("attack");
pHero->getAnimation()->setMovementEventCallFunc(this,
movementEvent_selector(HelloWorld::animationEvent));
m_bStart = false;
}
*/
/**/
}
if(m_bDead)
{
ComRender *pUIRender = static_cast<ComRender*>(m_pGameScene->getChildByTag(10007)->getComponent("GUIComponent"));
/* for 3.0 */
Node* pUILayer = static_cast<Node*>(pUIRender->getNode());
Layout* root = static_cast<Layout*>(pUILayer->getChildren().at(2));
LoadingBar *pHPLoadingBar = static_cast<LoadingBar*>(Helper::seekWidgetByName(root, "hp02_LoadingBar"));
LoadingBar *pMPLoadingBar = static_cast<LoadingBar*>(Helper::seekWidgetByName(root, "mp02_LoadingBar"));
// before
/*
cocos2d::ui::TouchGroup *pUILayer = static_cast<cocos2d::ui::TouchGroup*>(pUIRender->getNode());
cocos2d::ui::LoadingBar *pHPLoadingBar = static_cast<cocos2d::ui::LoadingBar*>(pUILayer->getWidgetByName("hp02_LoadingBar"));
cocos2d::ui::LoadingBar *pMPLoadingBar = static_cast<cocos2d::ui::LoadingBar*>(pUILayer->getWidgetByName("mp02_LoadingBar"));
*/
/**/
pHPLoadingBar->setPercent(m_fPercentage);
pMPLoadingBar->setPercent(m_fPercentage);
m_fPercentage -= 2.0f;
if (m_fPercentage < 0.0f) {
unscheduleUpdate();
}
}
}