当前位置: 首页>>代码示例>>C++>>正文


C++ Armature::getParent方法代码示例

本文整理汇总了C++中Armature::getParent方法的典型用法代码示例。如果您正苦于以下问题:C++ Armature::getParent方法的具体用法?C++ Armature::getParent怎么用?C++ Armature::getParent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Armature的用法示例。


在下文中一共展示了Armature::getParent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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();
        }
	}
	
}
开发者ID:6520874,项目名称:CocoStudioSamplesBasedOnCocos2d-x3.0,代码行数:61,代码来源:HelloWorldScene.cpp


注:本文中的Armature::getParent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。