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


C++ CCAnimation::addSpriteFrameWithFileName方法代码示例

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


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

示例1: onEnter

void GameObjHero::onEnter()
{
    CCNode::onEnter();
    this->setContentSize(CCSizeMake(85, 90));
    CCDirector *pDirector = CCDirector::sharedDirector();
    pDirector->getTouchDispatcher()->addTargetedDelegate(this, 0, true);
    CCSprite *obj = CCSprite::create("s_hurt.png");
    hurt = obj->getTexture();
    obj = CCSprite::create("s_jump.png");
    jump = obj->getTexture();
    mainsprite = CCSprite::create("s_1.png");
    //动画
    CCAnimation *animation = CCAnimation::create();
    animation->addSpriteFrameWithFileName("s_1.png");
    animation->addSpriteFrameWithFileName("s_2.png");
    animation->addSpriteFrameWithFileName("s_3.png");
    animation->addSpriteFrameWithFileName("s_4.png");
    animation->addSpriteFrameWithFileName("s_5.png");
    animation->addSpriteFrameWithFileName("s_6.png");
    animation->setDelayPerUnit(0.1f);
    animation->setRestoreOriginalFrame(true);
    //运行奔跑动画
    mainsprite->runAction(CCRepeatForever::create(CCAnimate::create(animation)));
    state = 0;
    addChild(mainsprite);
}
开发者ID:pandazheng,项目名称:LuoLiRunGame,代码行数:26,代码来源:GameObjHero.cpp

示例2:

std::map<int, cocos2d::CCAnimation*>* ShieldedObject::getShieldAnimations()
{
	if (shieldAnimations == NULL)
	{
		shieldAnimations = new map<int, cocos2d::CCAnimation*>;
		for (int i = 0; i < 1; i++)
		{
			CCAnimation *animation;
			animation = CCAnimation::create();
			animation->retain();
			animation->setDelayPerUnit(0.05f);
			animation->addSpriteFrameWithFileName("res/image/shield7.png");
			animation->addSpriteFrameWithFileName("res/image/shield6.png");
			animation->addSpriteFrameWithFileName("res/image/shield5.png");
			animation->addSpriteFrameWithFileName("res/image/shield4.png");
			animation->addSpriteFrameWithFileName("res/image/shield3.png");
			animation->addSpriteFrameWithFileName("res/image/shield2.png");
			animation->addSpriteFrameWithFileName("res/image/shield1.png");
			animation->addSpriteFrameWithFileName("res/image/shield.png");
			animation->addSpriteFrameWithFileName("res/image/shield.png");
			animation->addSpriteFrameWithFileName("res/image/shield.png");
			animation->addSpriteFrameWithFileName("res/image/shield1.png");
			animation->addSpriteFrameWithFileName("res/image/shield2.png");
			animation->addSpriteFrameWithFileName("res/image/shield3.png");
			animation->addSpriteFrameWithFileName("res/image/shield4.png");
			animation->addSpriteFrameWithFileName("res/image/shield5.png");
			animation->addSpriteFrameWithFileName("res/image/shield6.png");
			animation->addSpriteFrameWithFileName("res/image/shield7.png");
			animation->addSpriteFrameWithFileName("res/image/shield0.png");
			(*shieldAnimations)[i] = animation;
		}
	}
	return shieldAnimations;
}
开发者ID:wi-secret,项目名称:TestGame,代码行数:34,代码来源:ShieldedObject.cpp

示例3:

void TestAction::action1()
{
    CCAnimation* animation = CCAnimation::create();
    animation->addSpriteFrameWithFileName("role/pao0.png");
    animation->addSpriteFrameWithFileName("role/pao1.png");
    animation->addSpriteFrameWithFileName("role/pao2.png");
    animation->addSpriteFrameWithFileName("role/pao3.png");
    animation->addSpriteFrameWithFileName("role/pao4.png");
    animation->setDelayPerUnit(0.1f);
    animation->setRestoreOriginalFrame(true);
    animation->setLoops(-1);
    CCFiniteTimeAction *animate = CCAnimate::create(animation);
    this->runAction(animate);
}
开发者ID:Alencai,项目名称:cocostest,代码行数:14,代码来源:TestAction.cpp

示例4: rotateAction

void Coin::rotateAction()
{
	CCAnimation* action = CCAnimation::create();
	action->setDelayPerUnit(0.1f);
	action->setRestoreOriginalFrame(true);
	action->addSpriteFrameWithFileName("ring1.png");
	action->addSpriteFrameWithFileName("ring2.png");
	action->addSpriteFrameWithFileName("ring3.png");
	action->addSpriteFrameWithFileName("ring4.png");
	CCAnimate* animate = CCAnimate::create(action);
	CCRepeatForever* repeat = CCRepeatForever::create(animate);
	sprite->runAction(repeat);

}
开发者ID:pac94,项目名称:cpp,代码行数:14,代码来源:coin.cpp

示例5: SetIdleMotion

void Motion::SetIdleMotion()
{
    CCAnimation* animation = CCAnimation::create();
    animation->setDelayPerUnit(0.5f/3.0f);
    
    animation->addSpriteFrameWithFileName("breath1.png");
    animation->addSpriteFrameWithFileName("breath2.png");
    animation->addSpriteFrameWithFileName("breath3.png");
    animation->addSpriteFrameWithFileName("breath2.png");
    animation->addSpriteFrameWithFileName("breath1.png");
    
    _idleMotion = CCRepeatForever::create(CCAnimate::create(animation));
    _idleMotion->retain();

}
开发者ID:ChungH,项目名称:Knight-Run,代码行数:15,代码来源:Motion.cpp

示例6: SetAnimation

//怪物走动的动画
void  Monster::SetAnimation(const char *name_each,unsigned int num,bool run_directon)
{
	//设置方向
	if(MonsterDirecton!=run_directon)
	{   MonsterDirecton=run_directon;
	    m_MonsterSprite->setFlipX(run_directon);
	}

	//正在走动、攻击、受伤或已死亡,就返回
	if(IsRunning||IsAttack||IsHurt||Isdead)
		return;

	//设置动画
	CCAnimation* animation = CCAnimation::create();  
	for( int i=1;i<=num;i++)  
	{  
		char szName[100] = {0};  
		sprintf(szName,"%s%d.png",name_each,i);  
		animation->addSpriteFrameWithFileName(szName); //加载动画的帧  
	}  
	animation->setDelayPerUnit(0.1f);//每两张图片的时间间隔 
	animation->setRestoreOriginalFrame(true);  
	animation->setLoops(-1); //动画循环

	//将动画包装成一个动作
	CCAnimate* act=CCAnimate::create(animation);
	m_MonsterSprite->runAction(act);
	IsRunning=true;

}
开发者ID:appleappleapple,项目名称:GameOfFighting,代码行数:31,代码来源:Monster.cpp

示例7: AttackAnimation

//攻击动画
void  Monster::AttackAnimation(const char *name_each,const unsigned int num,bool run_directon)
{
	//正在走动、攻击、受伤或已死亡,就返回
	if(IsRunning||IsAttack||IsHurt||Isdead)
		return;

	CCAnimation* animation = CCAnimation::create();  
	for( int i=1;i<=num;i++)  
	{  
		char szName[100] = {0};  
		sprintf(szName,"%s%d.png",name_each,i);  
		animation->addSpriteFrameWithFileName(szName); //加载动画的帧  
	}  
	animation->setDelayPerUnit(0.1f);  
	animation->setRestoreOriginalFrame(true);  
	animation->setLoops(1); //动画循环1次  

	//将动画包装成一个动作
	CCAnimate* act=CCAnimate::create(animation);
	//创建回调动作,攻击结束后调用AttackEnd()
	CCCallFunc* callFunc=CCCallFunc::create(this,callfunc_selector(Monster::AttackEnd));
	//创建连续动作
	CCActionInterval* attackact=CCSequence::create(act,callFunc,NULL);

	m_MonsterSprite->runAction(attackact);  
	IsAttack=true;

}
开发者ID:appleappleapple,项目名称:GameOfFighting,代码行数:29,代码来源:Monster.cpp

示例8: moveBack

float Snake::moveBack()
{
	//CCSprite::initWithFile("snakeBack1.png");
	//pLife->setRotationY(180);
	deleteExploreShit();
	this->stopAllActions();
	CCAnimation* animation =CCAnimation::create();

	char str[20];
	for(int i=0;i<3;i++)
	{
		sprintf(str,"snakeBack%d.png",i + 1);
		animation->addSpriteFrameWithFileName(str);
	}
	animation->setDelayPerUnit(0.2f);
	animation->setRestoreOriginalFrame(true);
	myAction = CCRepeatForever::create(CCAnimate::create(animation));
	this->runAction(myAction);

	CCSize size = CCDirector::sharedDirector()->getWinSize();
	CCActionInterval *move = CCMoveTo::create(moveTime / 2,ccp(size.width, 12));
	moveTo = CCSequence::create(move/*,CCCallFuncN::create(this,callfuncN_selector(GameLayer::deleteAnimal))*/,NULL);

	this->runAction(moveTo);

	hasMoveBack = true;
	return moveTime / 2;
}
开发者ID:xiaolizi521,项目名称:Classes,代码行数:28,代码来源:Snake.cpp

示例9: init

bool Snake::init()
{
	bool bRet = false;
	do 
	{	
		CC_BREAK_IF(!CCSprite::initWithFile("snake1.png"));
		pLife->setPosition(ccp(pLife->getContentSize().width / 2,this->getContentSize().height + pLife->getContentSize().height));

		CCAnimation* animation =CCAnimation::create();
		//char *spriteImg[] = {"snake1.png","snake2.png","snake3.png","snake4.png","snake5.png","snake6.png","snake7.png"};

		char str[20];
		for(int i=0;i<7;i++)
		{
			sprintf(str,"snake%d.png",i + 1);
			animation->addSpriteFrameWithFileName(str);
		}
		animation->setDelayPerUnit(0.1f);
		animation->setRestoreOriginalFrame(true);
		myAction = CCRepeatForever::create(CCAnimate::create(animation));
		myAction->retain();
		CCSize size = CCDirector::sharedDirector()->getWinSize();
		this->setPosition(ccp(size.width, 12));	
		produceLoc = ccp(size.width, 12);

		bRet = true;
	} while (0);

	return bRet;
}
开发者ID:xiaolizi521,项目名称:Classes,代码行数:30,代码来源:Snake.cpp

示例10: showOpenBoxAni

void IOSStoreLayer::showOpenBoxAni(CCNode* pNode)
{
	//播放打开动画
	CCSprite* pBox = (CCSprite*)pNode;
	CCAnimation* pAnimation = CCAnimation::create();
	char filename[64] = {};
	for (size_t i = 0; i < 2; ++i)
	{
		sprintf(filename, "daoju_baoxiang%d.png", i+2);
		pAnimation->addSpriteFrameWithFileName(ResManager::getManager()->getSharedFilePath(g_storelayerPath+filename).c_str());
	}
	pAnimation->setDelayPerUnit(0.05f);
	pAnimation->setLoops(1);
	pBox->runAction(CCSequence::create(
		CCAnimate::create(pAnimation),
		CCDelayTime::create(0.15f),
		CCCallFuncN::create(this, callfuncN_selector(IOSStoreLayer::boxStartMove)),
		NULL));
	pBox->runAction(CCSequence::create(
		CCDelayTime::create(0.05f), 
		CCCallFuncN::create(this, callfuncN_selector(IOSStoreLayer::showRandStars)),
		NULL));
// 	//出现大的星星
// 	CCSprite* pBigStar = CCSprite::create("daoju_baoxiang_xiaoguo_2.png");
// 	pBox->addChild(pBigStar, 1, box_big_star_tag);
// 	pBigStar->setPosition(ccp(pBox->getContentSize().width/2 - 20, pBox->getContentSize().height/2));
// 	pBigStar->setScale(0.1f);
// 	pBigStar->runAction(CCSequence::create(
// 		CCScaleTo::create(0.2f, 1.0f),
// 		CCRemoveSelf::create(),
// 		NULL));
}
开发者ID:SongCF,项目名称:game-LostStar,代码行数:32,代码来源:IOSStoreLayer.cpp

示例11: setdie

void TollGateModel::setdie(){
    islife = false;
    mainbody->setVisible(false);
    boom->setVisible(true);
    this->stopAllActions();
    //±¬Õ¨¶¯»­
    CCAnimation* boomAnimation = CCAnimation::create();
    boomAnimation->addSpriteFrameWithFileName("Boom1.png");
    boomAnimation->addSpriteFrameWithFileName("Boom2.png");
    boomAnimation->addSpriteFrameWithFileName("Boom3.png");
    boomAnimation->addSpriteFrameWithFileName("Boom4.png");
    boomAnimation->addSpriteFrameWithFileName("Boom5.png");
    boomAnimation->setDelayPerUnit(0.1f);
    boomAnimation->setRestoreOriginalFrame(true);
    //boom->runAction(CCSequence::create(CCAnimate::create(boomAnimation),CCCallFuncN::create(this, callfuncN_selector(TollGateModel::restart)),NULL));
}
开发者ID:yesunsong,项目名称:PaoNiu,代码行数:16,代码来源:TollGateModel.cpp

示例12:

void Game2Scene::eat(float dt)
{
	CCSprite* player = (CCSprite*)this->getChildByTag(4);
	player->setTexture(CCTextureCache::sharedTextureCache()->addImage("monkey01.png"));
	//SEの再生
	//SimpleAudioEngine::sharedEngine()->playEffect(SE);
	//アニメーション
	CCAnimation* ani = CCAnimation::create();
	for (int i = 3; i <= 5; i++)
	{
		char szName[100] = { 0 };
		sprintf(szName, "monkey%02d.png", i);
		ani->addSpriteFrameWithFileName(szName);
	}
	ani->setDelayPerUnit(0.15 / 3);
	ani->setRestoreOriginalFrame(true);
	ani->setLoops(2);

	CCAnimate* act = CCAnimate::create(ani);
	player->runAction(act);
	//スコアシステム作成
	CCSize winSize = CCDirector::sharedDirector()->getWinSize();
	CCLabelTTF* Label = (CCLabelTTF*)this->getChildByTag(22);
	this->m_Count += 1;
	CCString* gamePoints = CCString::createWithFormat("%d", this->m_Count);
	Label->setString(gamePoints->getCString());
}
开发者ID:afresgamer,项目名称:FirstGame,代码行数:27,代码来源:Game2.cpp

示例13: Change

//换图片
void keyedit::Change()
{	
	CCAnimation* animation = CCAnimation::create();
	animation->addSpriteFrameWithFileName("key2.png");
	animation->setDelayPerUnit(2.8f / 14.0f);//必须设置否则不会动态播放
	animation->setRestoreOriginalFrame(false);//是否回到第一帧
	animation->setLoops(1);//重复次数 (-1:无限循环)
	CCFiniteTimeAction * animate = CCAnimate::create(animation);
	this->runAction(animate);
}
开发者ID:yuwei845433424,项目名称:0,代码行数:11,代码来源:keyedit.cpp

示例14: onEnter

void GameObjHero::onEnter()
{
	CCNode::onEnter();
	this->setContentSize(CCSizeMake(85,90));

	CCDirector::sharedDirector()->getTouchDispatcher()->addTargetedDelegate(this,0,true);

	CCSprite* mainsprite = CCSprite::create("catBody1.png");
	CCAnimation* animation = CCAnimation::create();
	animation->addSpriteFrameWithFileName("catBody1.png");
	animation->addSpriteFrameWithFileName("catBody2-4.png");
	animation->addSpriteFrameWithFileName("catBody3.png");
	animation->addSpriteFrameWithFileName("catBody2-4.png");
	animation->setDelayPerUnit(0.1f);
	animation->setRestoreOriginalFrame(true);
	mainsprite->runAction(CCRepeatForever::create(CCAnimate::create(animation)));
	addChild(mainsprite);

	CCSprite* tail = CCSprite::create("catTail.png");
	tail->setAnchorPoint(ccp(0.5,1));
	tail->setPosition(ccp(-5,-29));
	tail->setScale(0.5);
	tail->setRotation(20);
	tail->runAction(CCRepeatForever::create((CCActionInterval*)CCSequence::create(CCRotateBy::create(0.5,-40),CCRotateBy::create(0.5,40),NULL)));
	addChild(tail);

	lefthand = CCSprite::create("catHand1.png");
	lefthand->setAnchorPoint(ccp(1,0.5));
	lefthand->setPosition(ccp(-18,-20));
	addChild(lefthand);

	righthand = CCSprite::create("catHand2.png");
	righthand->setAnchorPoint(ccp(0,0.5));
	righthand->setPosition(ccp(18,-20));
	addChild(righthand);

	offset = ccp(0,0);

	isControl = false;

	schedule(schedule_selector(GameObjHero::releaseBullet),0.3f);
}
开发者ID:xuzekun,项目名称:MeowStarBattle,代码行数:42,代码来源:GameObjHero.cpp

示例15:

KDvoid Level1Scene::ScoreAnimation ( CCPoint tPos, const KDchar* szImgName, const KDchar* szImgName2 )
{
	m_pExplosion = CCSprite::create ( szImgName );
	m_pExplosion->setPosition ( tPos );
	this->addChild ( m_pExplosion,0,22 );
	
	CCAnimation*	pAnim = CCAnimation::create ( );		
	pAnim->addSpriteFrameWithFileName ( szImgName );
	pAnim->addSpriteFrameWithFileName ( szImgName2 );

	m_pExplosion->runAction
	(
		CCSequence::create
		(
			CCAnimate	::create ( pAnim ),
			CCCallFuncN	::create ( this, callfuncN_selector ( Level1Scene::spMoveFinished ) ), 
			KD_NULL
		) 
	);
}
开发者ID:mcodegeeks,项目名称:OpenKODE-Framework,代码行数:20,代码来源:Level1Scene.cpp


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