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


C++ CCComRender类代码示例

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


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

示例1: movementEvent_selector

void HelloWorld::update(float delta)
{
	if(m_bStart)
	{
		CCArmature *pHero = (CCArmature*)(m_pGameScene->getChildByTag(10005)->getComponent("CCArmature")->getNode());
		pHero->getParent()->setPositionX(pHero->getParent()->getPositionX() + m_fSpeed);
		CCArmature *pEnemy = (CCArmature*)(m_pGameScene->getChildByTag(10006)->getComponent("CCArmature")->getNode());

		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)
	{
		CCComRender *pUIRender = static_cast<CCComRender*>(m_pGameScene->getChildByTag(10007)->getComponent("GUIComponent"));
		UILayer *pUILayer = static_cast<UILayer*>(pUIRender->getNode());
		UILoadingBar *pHPLoadingBar = static_cast<UILoadingBar*>(pUILayer->getWidgetByName("hp02_LoadingBar"));
		UILoadingBar *pMPLoadingBar = static_cast<UILoadingBar*>(pUILayer->getWidgetByName("mp02_LoadingBar"));

		pHPLoadingBar->setPercent(m_fPercentage);
		pMPLoadingBar->setPercent(m_fPercentage);

		m_fPercentage -= 2.0f;
        if (m_fPercentage < 0.0f) {
            unscheduleUpdate();
        }
	}
	
}
开发者ID:shujunqiao,项目名称:CocoStudioSamples,代码行数:34,代码来源:HelloWorldScene.cpp

示例2: defaultPlay

void ParticleComponentTest::defaultPlay()
{
	CCComRender* Particle = static_cast<CCComRender*>(m_rootNode->getChildByTag(10020)->getComponent("CCParticleSystemQuad"));
	CCActionInterval*  jump = CCJumpBy::create(5, ccp(-500,0), 50, 4);
	CCFiniteTimeAction*  action = CCSequence::create( jump, jump->reverse(), NULL);
	Particle->getNode()->runAction(action);
}
开发者ID:fuguelike,项目名称:cocos2d-x,代码行数:7,代码来源:SceneEditorTest.cpp

示例3: update

/// 这里实现的是动画移动过程;
/// 重点:CCArmature *pButterFlyFish= (CCArmature *)(pFishRender->getNode()); 
void HelloWorld::update( float delta )
{
	 
	/// 获取节点信息 只有节点信息才是我们设置的信息
	CCNode* pFishNode = m_pLoginScene->getChildByTag(10009);
	CCPoint p1 = pFishNode->getPosition();	
	//获取comrender组件 
	CCComRender *pFishRender = (CCComRender*)(m_pLoginScene->getChildByTag(10009)->getComponent("CCArmature"));  
	//转换为armature  这里的armature是我们在动画中制作的相关数据了,因此下面我们要获得信息将会是我们在动画制作的数据
	/// 而不是在场景制作中的数据;
	CCArmature *pButterFlyFish= (CCArmature *)(pFishRender->getNode()); 
	/// 这里获得动画中的坐标
	CCPoint pt = pButterFlyFish->getPosition();

	if (!m_bDirection)
	{
		p1.x -= 2.0f;
		if (10 > p1.x)
		{
			m_bDirection = true;
		}
	}
	else
	{
		p1.x += 2.0f;
		if (900 < p1.x)
		{
			m_bDirection = false;
		}
	}
	pFishNode->setPosition(p1);
}
开发者ID:DionysosLai,项目名称:Coco2d-xRes,代码行数:34,代码来源:使用.cpp

示例4: ccp

void ArmatureComponentTest::defaultPlay()
{
	CCComRender *pBlowFish = static_cast<CCComRender*>(m_rootNode->getChildByTag(10007)->getComponent("CCArmature"));
	pBlowFish->getNode()->runAction(CCMoveBy::create(10.0f, ccp(-1000.0f, 0)));

	CCComRender *pButterflyfish = static_cast<CCComRender*>(m_rootNode->getChildByTag(10008)->getComponent("CCArmature"));
	pButterflyfish->getNode()->runAction(CCMoveBy::create(10.0f, ccp(-1000.0f, 0)));

}
开发者ID:fuguelike,项目名称:cocos2d-x,代码行数:9,代码来源:SceneEditorTest.cpp

示例5: getFish

CCArmature* SceneEditorTestLayer::getFish(int nTag, const char *pszName)
{
	if (m_pCurNode == NULL)
	{
		return NULL;
	}
	CCComRender *pFishRender = (CCComRender*)(m_pCurNode->getChildByTag(nTag)->getComponent(pszName));
	return (CCArmature *)(pFishRender->getRender());
}
开发者ID:chenxu111,项目名称:Cocos2d-x-For-CocoStudio,代码行数:9,代码来源:SceneEditorTestScene.cpp

示例6: CC_BREAK_IF

void ArmaturePlayAction::done()
{
	do 
	{
		CCNode *pNode = SceneReader::sharedSceneReader()->getNodeByTag(_nTag);
		CC_BREAK_IF(pNode == NULL);
		CCComRender *pRender = (CCComRender*)(pNode->getComponent(_comName.c_str()));
		CC_BREAK_IF(pRender == NULL);
		CCArmature *pAr = (CCArmature *)(pRender->getNode());
		CC_BREAK_IF(pAr == NULL);
		pAr->getAnimation()->play(_aniname.c_str());
	} while (0);
}
开发者ID:harveyyang,项目名称:DragonBones_Learn,代码行数:13,代码来源:acts.cpp

示例7: CC_BREAK_IF

void ArmatureActionState::removeAll()
{
	do 
	{
		CCNode *pNode = SceneReader::sharedSceneReader()->getNodeByTag(_nTag);
		CC_BREAK_IF(pNode == NULL);
		CCComRender *pRender = (CCComRender*)(pNode->getComponent(_ComName.c_str()));
		CC_BREAK_IF(pRender == NULL);
		CCArmature *pAr = (CCArmature *)(pRender->getNode());
		CC_BREAK_IF(pAr == NULL);
		TriggerMng::sharedTriggerMng()->removeArmatureMovementCallBack(pAr, this, movementEvent_selector(ArmatureActionState::animationEvent));
	} while (0);
}
开发者ID:pipu,项目名称:CocoStudioConnector,代码行数:13,代码来源:cons.cpp

示例8: CCComRender

CCComRender* CCComRender::create(cocos2d::CCNode *pNode, const char *comName)
{
    CCComRender * pRet = new CCComRender(pNode, comName);
    if (pRet != NULL && pRet->init())
    {
        pRet->autorelease();
    }
    else
    {
        CC_SAFE_DELETE(pRet);
    }
        return pRet;
}
开发者ID:ECNU-ZR,项目名称:physwf-c-lab,代码行数:13,代码来源:CCComRender.cpp

示例9: animationEvent

void HelloWorld::animationEvent(CCArmature *pArmature,
					MovementEventType movementType, const char *movementID)
{
    CCComRender *render = (CCComRender*)(m_pGameScene->getChildByTag(10006)->getComponent("CCArmature"));
	CCArmature *pEnemy = (CCArmature*)(render->getNode());

	if (movementType == COMPLETE)
	{
		pEnemy->getAnimation()->play("death");
		pArmature->getAnimation()->setMovementEventCallFunc(NULL, NULL);
		m_bDead = true;
	}
	
}
开发者ID:19743813,项目名称:CocoStudioSamples,代码行数:14,代码来源:HelloWorldScene.cpp

示例10: CC_BREAK_IF

bool ArmatureActionState::init()
{
	do 
	{
		CCNode *pNode = SceneReader::sharedSceneReader()->getNodeByTag(_nTag);
		CC_BREAK_IF(pNode == NULL);
		CCComRender *pRender = (CCComRender*)(pNode->getComponent(_comName.c_str()));
		CC_BREAK_IF(pRender == NULL);
		CCArmature *pAr = (CCArmature *)(pRender->getNode());
		CC_BREAK_IF(pAr == NULL);
		TriggerMng::getInstance()->addArmatureMovementCallBack(pAr, this, movementEvent_selector(ArmatureActionState::animationEvent));
	} while (0);
	
	return true;
}
开发者ID:harveyyang,项目名称:DragonBones_Learn,代码行数:15,代码来源:cons.cpp

示例11: switch

void UIComponentTest::touchEvent(CCObject *pSender, TouchEventType type)
{
	switch (type)
	{
	case TOUCH_EVENT_BEGAN:
		{
			CCComRender *pBlowFish = static_cast<CCComRender*>(m_rootNode->getChildByTag(10010)->getComponent("CCArmature"));
			pBlowFish->getNode()->runAction(CCMoveBy::create(10.0f, ccp(-1000.0f, 0)));

			CCComRender *pButterflyfish = static_cast<CCComRender*>(m_rootNode->getChildByTag(10011)->getComponent("CCArmature"));
			pButterflyfish->getNode()->runAction(CCMoveBy::create(10.0f, ccp(-1000.0f, 0)));
		}
		break;
	default:
		break;
	}
}
开发者ID:fuguelike,项目名称:cocos2d-x,代码行数:17,代码来源:SceneEditorTest.cpp

示例12: init

// on "init" you need to initialize your instance
bool HelloWorld::init()
{
    //////////////////////////////
    // 1. super init first
    if ( !CCLayer::init() )
    {
        return false;
    }
	m_fTime = 0.0f;
	m_bStart = false;
	m_bDead = false;
	m_fPercentage = 100.0f;
	m_fSpeed = 4.0f;
	m_fAttackDis = 120.0f;

	m_pGameScene = NULL;
    
	CCNode *pGameScene = SceneReader::sharedSceneReader()->createNodeWithSceneFile("FightScene.json");
	m_pGameScene = pGameScene;
	this->addChild(pGameScene);

    CCComRender *render = (CCComRender*)(m_pGameScene->getChildByTag(10005)->getComponent("CCArmature"));
                                         
    CCArmature *pArmature = (CCArmature*)(render->getNode());
	
    pArmature->getAnimation()->play("run");
	
    m_bStart = true;

    CCMenuItemFont *itemBack = CCMenuItemFont::create("End", this, menu_selector(HelloWorld::menuCloseCallback));
    itemBack->setColor(ccc3(255, 255, 255));
    itemBack->setPosition(ccp(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25));
    CCMenu *menuBack = CCMenu::create(itemBack, NULL);
    menuBack->setPosition(CCPointZero);
    menuBack->setZOrder(4);
    
    this->addChild(menuBack);

	scheduleUpdate();

    return true;
}
开发者ID:19743813,项目名称:CocoStudioSamples,代码行数:43,代码来源:HelloWorldScene.cpp

示例13: setPropertyFromJsonDict

    CCNode* CCJsonReader::createObject(cs::CSJsonDictionary * inputFiles, CCNode* parenet)
    {
        const char* className = inputFiles->getItemStringValue("classname"); 

        if(strcmp(className, "CCNode") == 0)
        {
            CCNode* gb = NULL;
            if(NULL == parenet)
            {
                gb = CCNode::create();
            }
            else
            {
                gb = CCNode::create();
                parenet->addChild(gb);
            }
            
            setPropertyFromJsonDict(gb, inputFiles);
    
            int count = inputFiles->getArrayItemCount("components");
            for (int i = 0; i < count; i++)
            {
                cs::CSJsonDictionary * subDict = inputFiles->getSubItemFromArray("components", i);
                if (!subDict)
                   break;
                const char *comName = subDict->getItemStringValue("classname");
                const char *file = subDict->getItemStringValue("file");
                const char *pComName = subDict->getItemStringValue("name");
                if (file == NULL || strcmp(file, "") == 0)
                {
                    continue;
                }
                CCAssert(file != NULL, "file must be not NULL!");
                std::string pPath = cocos2d::CCFileUtils::sharedFileUtils()->fullPathForFilename(file);

                if (comName != NULL && strcmp(comName, "CCSprite") == 0)
                {
                    cocos2d::CCSprite *pSprite = CCSprite::create(pPath.c_str());
					
                    CCComRender *pRender = CCComRender::create(pSprite, "CCSprite");
                    if (pComName != NULL)
                    {
                        pRender->setName(pComName);
                    }
                    
                    gb->addComponent(pRender);
                }
                else if(comName != NULL && strcmp(comName, "CCTMXTiledMap") == 0)
                {
                    cocos2d::CCTMXTiledMap *pTmx = CCTMXTiledMap::create(pPath.c_str());
                    CCComRender *pRender = CCComRender::create(pTmx, "CCTMXTiledMap");
                    if (pComName != NULL)
                    {
                        pRender->setName(pComName);
                    }
                    gb->addComponent(pRender);
                }
                else if(comName != NULL && strcmp(comName, "CCParticleSystemQuad") == 0)
                {
                    std::string::size_type pos =  pPath.find(".plist");
                    if (pos  == pPath.npos)
                    {
                        continue;
                    }
                    cocos2d::CCParticleSystemQuad *pParticle = CCParticleSystemQuad::create(pPath.c_str());

					pParticle->setPosition(0, 0);
                    CCComRender *pRender = CCComRender::create(pParticle, "CCParticleSystemQuad");
                    if (pComName != NULL)
                    {
                        pRender->setName(pComName);
                    }
                    gb->addComponent(pRender);
                }
                else if(comName != NULL && strcmp(comName, "CCArmature") == 0)
                {
                    std::string reDir = pPath;
                    std::string file_path = "";
                    size_t pos = reDir.find_last_of('/');
                    if (pos != std::string::npos)
                    {
                        file_path = reDir.substr(0, pos+1);
                    }
                    unsigned long size = 0;
                    const char *des = (char*)(cocos2d::CCFileUtils::sharedFileUtils()->getFileData(pPath.c_str(),"r" , &size));
			        cs::CSJsonDictionary *jsonDict = new cs::CSJsonDictionary();
			        jsonDict->initWithDescription(des);
                    if(NULL == des || strcmp(des, "") == 0)
                    {
                        CCLog("read json file[%s] error!\n", pPath.c_str());
                    }
                    
                    int childrenCount = DICTOOL->getArrayCount_json(jsonDict, "armature_data");
                    cs::CSJsonDictionary* subData = DICTOOL->getDictionaryFromArray_json(jsonDict, "armature_data", 0);
                    const char *name = DICTOOL->getStringValue_json(subData, "name");

                    childrenCount = DICTOOL->getArrayCount_json(jsonDict, "config_file_path");
                    for (int i = 0; i < childrenCount; ++i)
                    {
                        const char* plist = DICTOOL->getStringValueFromArray_json(jsonDict, "config_file_path", i);
//.........这里部分代码省略.........
开发者ID:huangchonghai,项目名称:Cocos2d-x-For-CocoStudio,代码行数:101,代码来源:CCJsonReader.cpp

示例14: setPropertyFromJsonDict

	CCNode* SceneReader::createObject(const rapidjson::Value &root, cocos2d::CCNode* parent)
    {
        const char *className = DICTOOL->getStringValue_json(root, "classname"); //inputFiles->getItemStringValue("classname");
        if(strcmp(className, "CCNode") == 0)
        {
            CCNode* gb = NULL;
            if(NULL == parent)
            {
                gb = CCNode::create();
            }
            else
            {
                gb = CCNode::create();
                parent->addChild(gb);
            }
            
            setPropertyFromJsonDict(root, gb);
    
            int count = DICTOOL->getArrayCount_json(root, "components");
            for (int i = 0; i < count; i++)
            {
                const rapidjson::Value &subDict = DICTOOL->getSubDictionary_json(root, "components", i);
                if (!DICTOOL->checkObjectExist_json(subDict))
                {
                    break;
                }

                const char *comName = DICTOOL->getStringValue_json(subDict, "classname");
				const char *pComName = DICTOOL->getStringValue_json(subDict, "name");
				const rapidjson::Value &fileData = DICTOOL->getSubDictionary_json(subDict, "fileData");
                std::string pPath;
                std::string pPlistFile;
				int nResType = 0;
				//if (fileData != NULL)
                if (DICTOOL->checkObjectExist_json(fileData))
                {
					const char *file = DICTOOL->getStringValue_json(fileData, "path");
					nResType = DICTOOL->getIntValue_json(fileData, "resourceType", - 1);
					const char *plistFile = DICTOOL->getStringValue_json(fileData, "plistFile");
					if (file != NULL)
					{
						pPath.append(cocos2d::CCFileUtils::sharedFileUtils()->fullPathForFilename(file));
					}

					if (plistFile != NULL)
					{
						pPlistFile.append(cocos2d::CCFileUtils::sharedFileUtils()->fullPathForFilename(plistFile));
					}
                }

                if (comName != NULL && strcmp(comName, "CCSprite") == 0)
                {
					cocos2d::CCSprite *pSprite = NULL;

					if (nResType == 0)
					{
						if (pPath.find(".png") == pPath.npos)
						{
							continue;
						}
						pSprite = CCSprite::create(pPath.c_str());
					}
					else if (nResType == 1)
					{
						std::string pngFile = pPlistFile;
						std::string::size_type pos = pngFile.find(".plist");
						if (pos  == pPath.npos)
						{
							continue;
						}
						pngFile.replace(pos, pngFile.length(), ".png");
						CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile(pPlistFile.c_str(), pngFile.c_str());
						pSprite = CCSprite::createWithSpriteFrameName(pPath.c_str());
					}
					else
					{
						continue;
					}
					
                    CCComRender *pRender = CCComRender::create(pSprite, "CCSprite");
                    if (pComName != NULL)
                    {
                        pRender->setName(pComName);
                    }
                    
                    gb->addComponent(pRender);
					if (_pListener && _pfnSelector)
					{
						(_pListener->*_pfnSelector)(pSprite, (void*)(&subDict));
					}
                }
                else if(comName != NULL && strcmp(comName, "CCTMXTiledMap") == 0)
                {
					cocos2d::CCTMXTiledMap *pTmx = NULL;
					if (nResType == 0)
					{
						if (pPath.find(".tmx") == pPath.npos)
						{
							continue;
						}
//.........这里部分代码省略.........
开发者ID:76299500,项目名称:cocos2d-x,代码行数:101,代码来源:SceneReader.cpp


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