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


C++ CCArmature::getAnimation方法代码示例

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


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

示例1: init

// on "init" you need to initialize your instance
bool HelloWorld::init()
{
    //////////////////////////////
    // 1. super init first
    if ( !CCLayer::init() )
    {
        return false;
    }
    
    CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
    CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();

    /////////////////////////////
    // 2. add a menu item with "X" image, which is clicked to quit the program
    //    you may modify it.

    // add a "close" icon to exit the progress. it's an autorelease object
    CCMenuItemImage *pCloseItem = CCMenuItemImage::create(
                                        "CloseNormal.png",
                                        "CloseSelected.png",
                                        this,
                                        menu_selector(HelloWorld::menuCloseCallback));
    
	pCloseItem->setPosition(ccp(origin.x + visibleSize.width - pCloseItem->getContentSize().width/2 ,
                                origin.y + pCloseItem->getContentSize().height/2));

    // create menu, it's an autorelease object
    CCMenu* pMenu = CCMenu::create(pCloseItem, NULL);
    pMenu->setPosition(CCPointZero);
    this->addChild(pMenu, 1);

    /////////////////////////////
    // 3. add your codes below...
	
	CCArmatureDataManager::sharedArmatureDataManager()->addArmatureFileInfo("hero/Hero.ExportJson");
	CCArmature* armature = CCArmature::create("Hero");
	armature->getAnimation()->play("attack");
	armature->setScale(1.5);
	armature->setPosition(ccp(visibleSize.width*0.25, visibleSize.height*0.25));

	addChild(armature);
    
    return true;
}
开发者ID:253627764,项目名称:CocoStudioSamples,代码行数:45,代码来源:HelloWorldScene.cpp

示例2: 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

示例3: serialize


//.........这里部分代码省略.........
			}
			else if(strcmp(pClassName, "CCArmature") == 0)
			{
				std::string file_extension = strFilePath;
				size_t pos = strFilePath.find_last_of('.');
				if (pos != std::string::npos)
				{
					file_extension = strFilePath.substr(pos, strFilePath.length());
					std::transform(file_extension.begin(),file_extension.end(), file_extension.begin(), (int(*)(int))toupper);
				}
				if (file_extension == ".JSON" || file_extension == ".EXPORTJSON")
				{
					rapidjson::Document doc;
					if(!readJson(strFilePath.c_str(), doc))
					{
						CCLog("read json file[%s] error!\n", strFilePath.c_str());
						continue;
					}
					const rapidjson::Value &subData = DICTOOL->getDictionaryFromArray_json(doc, "armature_data", 0);
					const char *name = DICTOOL->getStringValue_json(subData, "name");
					CCArmatureDataManager::sharedArmatureDataManager()->addArmatureFileInfo(strFilePath.c_str());
					CCArmature *pAr = CCArmature::create(name);
					m_pRender = pAr;
					m_pRender->retain();
					const char *actionName = NULL;
					if (pCocoNode != NULL)
					{
						actionName = pCocoNode[6].GetValue();//DICTOOL->getStringValue_json(*v, "selectedactionname");
					}
					else
					{
						actionName = DICTOOL->getStringValue_json(*v, "selectedactionname");
					}
					if (actionName != NULL && pAr->getAnimation() != NULL)
					{
						pAr->getAnimation()->play(actionName);
					}
                    bRet = true;
				}
				else if (file_extension == ".CSB")
				{
					unsigned long size = 0;
					unsigned char *pBytes = NULL;
					std::string binaryFilePath = CCFileUtils::sharedFileUtils()->fullPathForFilename(strFilePath.c_str());
					pBytes = cocos2d::CCFileUtils::sharedFileUtils()->getFileData(binaryFilePath.c_str(), "rb", &size);
					CC_BREAK_IF(pBytes == NULL || strcmp((char*)pBytes, "") == 0);
					CocoLoader tCocoLoader;
					if (tCocoLoader.ReadCocoBinBuff((char*)pBytes))
					{
						stExpCocoNode *tpRootCocoNode = tCocoLoader.GetRootCocoNode();
						rapidjson::Type tType = tpRootCocoNode->GetType(&tCocoLoader);
						if (rapidjson::kObjectType  == tType)
						{
                            int count = tpRootCocoNode->GetChildNum();
                            stExpCocoNode *tpChildArray = tpRootCocoNode->GetChildArray();
                            for (int i = 0; i < count; ++i)
                            {
                                std::string key = tpChildArray[i].GetName(&tCocoLoader);
                                const char *str = tpChildArray[i].GetValue();
                                if (key.compare("armature_data") == 0)
                                {
                                    int length = tpChildArray[i].GetChildNum();
                                    stExpCocoNode *armature_dataArray = tpChildArray[i].GetChildArray();
                                    if (length < 1)
                                    {
                                        continue;
开发者ID:ECNU-ZR,项目名称:physwf-c-lab,代码行数:67,代码来源:CCComRender.cpp

示例4: init

// on "init" you need to initialize your instance
bool LayerChatWindow::init()
{
	//////////////////////////////
	// 1. super init first
	if ( !CCLayer::init() )
	{
		return false;
	}
	lstStringMessage.clear();
	lstStringMessage.push_back("Nhanh lên nào (14)!");
	lstStringMessage.push_back("Mạng lag quá (9)!");
	lstStringMessage.push_back("Bài xấu quá (3)!");
	lstStringMessage.push_back("Hehe, lên nóc nhà\nmà bắt con gà (6)");
	lstStringMessage.push_back("Nhất rồi, haha (1)");
	lstStringMessage.push_back("Đánh gà thế (11)!");
	lstStringMessage.push_back("Đỏ vãi lúa (13)!");
	lstStringMessage.push_back("Nhọ như chó mực (5)!");

	//return true;

	CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
	CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();
	_count = 100;
	layerButton = UILayer::create();
	layerButton->addWidget(GUIReader::shareReader()->widgetFromJsonFile("LayerChatWindow_1.ExportJson"));
	this->addChild(layerButton);
	layerButton->setTouchPriority(-128);
	this->setTouchEnabled(true);

	//Get all chat button
	for( int i = 1; i <= 8; i++ ){
		UIButton* btnChat = dynamic_cast<UIButton*>(layerButton->getWidgetByName( CCString::createWithFormat("btnChat%d", i)->getCString() ));
		btnChat->setTitleText( lstStringMessage.at(i-1).c_str() );
		btnChat->addTouchEventListener(this,(SEL_TouchEvent)&LayerChatWindow::onButtonChats);
	}
	UIButton* btnClose = dynamic_cast<UIButton*>(layerButton->getWidgetByName("btnClose"));
	btnClose->addTouchEventListener(this,(SEL_TouchEvent)&LayerChatWindow::onButtonClose);
	//
	UIButton* btnSend = dynamic_cast<UIButton*>(layerButton->getWidgetByName("btnSend"));
	btnSend->addTouchEventListener(this,(SEL_TouchEvent)&LayerChatWindow::onButtonSend);

	txtChat = dynamic_cast<UITextField*>(layerButton->getWidgetByName("txtChat"));
	txtChat->setText("");
	txtChat->setPlaceHolder("Noi dung");
	txtChat->setTextHorizontalAlignment(kCCTextAlignmentCenter);
	txtChat->setTextVerticalAlignment(kCCVerticalTextAlignmentCenter);
	txtChat->addEventListenerTextField(this, textfieldeventselector(LayerChatWindow::textFieldEvent));

	UIPanel* pEmo = dynamic_cast<UIPanel*>(layerButton->getWidgetByName("pEmo"));
	UIImageView* pImg = dynamic_cast<UIImageView*>(layerButton->getWidgetByName("Image_25_0"));
	//Add all emo to this
	int i = 1;
// 	CCArmatureDataManager::sharedArmatureDataManager()->removeArmatureFileInfo(CCString::createWithFormat("onion%d.ExportJson", 1)->getCString());
// 	CCArmatureDataManager::sharedArmatureDataManager()->addArmatureFileInfo(CCString::createWithFormat("onion%d.ExportJson", 1)->getCString());
	int row=-1, col = 1;
	int widthOfPage = 580;
	int numOfCols = 9;
	int space = 10;
	int widthOfImage = 50;
	int startPosX = widthOfPage/2 - (widthOfImage+space)*numOfCols/2 - 300;
	int startPosY = space - 100;
	lstEmo.clear();
	for( int i = 1; i<=16; i++ ){
		CCArmature *armature = CCArmature::create(CCString::createWithFormat("onion%d", 1)->getCString());
		armature->getAnimation()->playByIndex(i-1);
		RichElementCustomNode* recustom = RichElementCustomNode::create(1, ccWHITE, 255, armature);
		RichText* _richText = RichText::create();
		_richText->setContentSize( armature->getContentSize() );
		_richText->pushBackElement(recustom); 
		if( col> numOfCols ){
			row++;
			col = 1;
		}
		_richText->setAnchorPoint(ccp(0, 1));
		_richText->setPosition(ccp( startPosX + 60*(col-1)
			, -1*row*50 - startPosY - (row+1)*space ));
		_richText->addTouchEventListener(this,(SEL_TouchEvent)&LayerChatWindow::OnEmoClick);

		lstEmo.push_back( armature );

		UIButton* b = UIButton::create();
		b->setPosition(ccp( startPosX + 60*(col-1)
			, -1*row*50 - startPosY - (row+1)*space ));
		b->setAnchorPoint(ccp(0, 1));
		b->setContentSize( armature->getContentSize() );
		b->addTouchEventListener(this,(SEL_TouchEvent)&LayerChatWindow::OnEmoClick);
		b->loadTextures("emo_blank.png", "", "");
		b->setTag(i);

		pImg->addChild( _richText );
		pImg->addChild( b );
		//CCLOG("button w: %lf h: %lf", b->getContentSize().width, b->getContentSize().height);
		col++;
	}
	return true;
}
开发者ID:mrktj,项目名称:iCasino_v2,代码行数:97,代码来源:LayerChatWindow.cpp

示例5: serialize

bool CCComRender::serialize(void* r)
{
	bool bRet = false;
	do 
	{
		CC_BREAK_IF(r == NULL);
		rapidjson::Value *v = (rapidjson::Value *)r;
		const char *pClassName = DICTOOL->getStringValue_json(*v, "classname");
		CC_BREAK_IF(pClassName == NULL);
		const char *pComName = DICTOOL->getStringValue_json(*v, "name");
		if (pComName != NULL)
		{
			setName(pComName);
		}
		else
		{
			setName(pClassName);
		}
		const rapidjson::Value &fileData = DICTOOL->getSubDictionary_json(*v, "fileData");
		CC_BREAK_IF(!DICTOOL->checkObjectExist_json(fileData));
		const char *pFile = DICTOOL->getStringValue_json(fileData, "path");
		const char *pPlist = DICTOOL->getStringValue_json(fileData, "plistFile");
		CC_BREAK_IF(pFile == NULL && pPlist == NULL);
		std::string strFilePath;
		std::string strPlistPath;
		if (pFile != NULL)
		{
			strFilePath.assign(cocos2d::CCFileUtils::sharedFileUtils()->fullPathForFilename(pFile));
		}
		if (pPlist != NULL)
		{
			strPlistPath.assign(cocos2d::CCFileUtils::sharedFileUtils()->fullPathForFilename(pPlist));
		}
		int nResType = DICTOOL->getIntValue_json(fileData, "resourceType", -1);
		if (nResType == 0)
		{
			if (strcmp(pClassName, "CCSprite") == 0 && strFilePath.find(".png") != strFilePath.npos)
			{
				m_pRender = CCSprite::create(strFilePath.c_str());
			}
			else if(strcmp(pClassName, "CCTMXTiledMap") == 0 && strFilePath.find(".tmx") != strFilePath.npos)
			{
				m_pRender = CCTMXTiledMap::create(strFilePath.c_str());
			}
			else if(strcmp(pClassName, "CCParticleSystemQuad") == 0 && strFilePath.find(".plist") != strFilePath.npos)
			{
				m_pRender = CCParticleSystemQuad::create(strFilePath.c_str());
                m_pRender->setPosition(ccp(0.0f, 0.0f));
			}
			else if(strcmp(pClassName, "CCArmature") == 0)
			{
				std::string reDir = strFilePath;
				std::string file_path = "";
				size_t pos = reDir.find_last_of('/');
				if (pos != std::string::npos)
				{
					file_path = reDir.substr(0, pos+1);
				}
				rapidjson::Document doc;
				if(!readJson(strFilePath.c_str(), doc))
				{
					CCLog("read json file[%s] error!\n", strFilePath.c_str());
					continue;
				}
				const rapidjson::Value &subData = DICTOOL->getDictionaryFromArray_json(doc, "armature_data", 0);
				const char *name = DICTOOL->getStringValue_json(subData, "name");
				CCArmatureDataManager::sharedArmatureDataManager()->addArmatureFileInfo(strFilePath.c_str());
				CCArmature *pAr = CCArmature::create(name);
				m_pRender = pAr;
				const char *actionName = DICTOOL->getStringValue_json(*v, "selectedactionname");
				if (actionName != NULL && pAr->getAnimation() != NULL)
				{
					pAr->getAnimation()->play(actionName);
				}
			}
			else if(strcmp(pClassName, "GUIComponent") == 0)
			{
				cocos2d::gui::TouchGroup* tg = cocos2d::gui::TouchGroup::create();
				cocos2d::gui::Widget* widget = cocos2d::extension::GUIReader::shareReader()->widgetFromJsonFile(strFilePath.c_str());
				tg->addWidget(widget);
				m_pRender = tg;
			}
			else
			{
				CC_BREAK_IF(true);
			}
		}
		else if (nResType == 1)
		{
			if (strcmp(pClassName, "CCSprite") == 0)
			{
				std::string strPngFile = strPlistPath;
				std::string::size_type pos = strPngFile.find(".plist");
				if (pos  == strPngFile.npos)
				{
					continue;
				}
				strPngFile.replace(pos, strPngFile.length(), ".png");
				CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile(strPlistPath.c_str(), strPngFile.c_str());
				m_pRender = CCSprite::createWithSpriteFrameName(strFilePath.c_str());
//.........这里部分代码省略.........
开发者ID:AlxZues,项目名称:cocos2d-x-1,代码行数:101,代码来源:CCComRender.cpp

示例6: createAnimation

CCArmature* AnimLoader::createAnimation(const char *resName, const char *animName)
{
	CCArmature *armature = CCArmature::create(resName);
	armature->getAnimation()->play(animName, 0, 0, -1, 0);
	return armature;
}
开发者ID:tangLovemi,项目名称:ThreeKingdom-src-and-scrips,代码行数:6,代码来源:AnimLoader.cpp

示例7: createObject


//.........这里部分代码省略.........
                    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);
                        if (plist == NULL)
                        {
                            continue;
                        }
                        std::string plistpath;
                        plistpath += file_path;
                        plistpath.append(plist);
                        cocos2d::CCDictionary *root = CCDictionary::createWithContentsOfFile(plistpath.c_str());
                        CCDictionary* metadata = DICTOOL->getSubDictionary(root, "metadata");
                        const char* textureFileName = DICTOOL->getStringValue(metadata, "textureFileName");

                        std::string textupath;
                        textupath += file_path;
                        textupath.append(textureFileName);

                        CCArmatureDataManager::sharedArmatureDataManager()->addArmatureFileInfo(textupath.c_str(), plistpath.c_str(), pPath.c_str());
                        
                    }
                    
                    CCArmature *pAr = CCArmature::create(name);
                    CCComRender *pRender = CCComRender::create(pAr, "CCArmature");
                    if (pComName != NULL)
                    {
                        pRender->setName(pComName);
                    }
                    gb->addComponent(pRender);
					const char *actionName = DICTOOL->getStringValue_json(subDict, "selectedactionname"); 
					if (actionName != NULL && pAr->getAnimation() != NULL)
					{
						pAr->getAnimation()->play(actionName);
					}
					if (_pListener && _pfnSelector)
					{
						(_pListener->*_pfnSelector)(pAr, (void*)(&subDict));
					}
                }
                else if(comName != NULL && strcmp(comName, "CCComAudio") == 0)
                {
					CCComAudio *pAudio = NULL;
					if (nResType == 0)
					{
						pAudio = CCComAudio::create();
					}
					else
					{
						continue;
					}
                    pAudio->preloadEffect(pPath.c_str());
                    gb->addComponent(pAudio);
					if (_pListener && _pfnSelector)
					{
						(_pListener->*_pfnSelector)(pAudio, (void*)(&subDict));
					}
                }
                else if(comName != NULL && strcmp(comName, "CCComAttribute") == 0)
                {
                    CCComAttribute *pAttribute = NULL;
					if (nResType == 0)
					{
						pAttribute = CCComAttribute::create();
开发者ID:76299500,项目名称:cocos2d-x,代码行数:67,代码来源:SceneReader.cpp

示例8: defaultPlay

void EffectComponentTest::defaultPlay()
{
	CCComRender *pRender = static_cast<CCComRender*>(m_rootNode->getChildByTag(10015)->getComponent("CCArmature"));
	CCArmature *pAr = static_cast<CCArmature*>(pRender->getNode());
	pAr->getAnimation()->setMovementEventCallFunc(this, movementEvent_selector(EffectComponentTest::animationEvent));
}
开发者ID:fuguelike,项目名称:cocos2d-x,代码行数:6,代码来源:SceneEditorTest.cpp


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