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


C++ CCAnimate::setDuration方法代码示例

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


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

示例1: getActionWithAnimate

CCFiniteTimeAction* AppConfig::getActionWithAnimate(const char* animateName, float duration)
{
	CCAnimation* pAnimation = CCAnimationCache::sharedAnimationCache()->animationByName(animateName);
	if(pAnimation){
		CCAnimate* pAnimate = CCAnimate::create(pAnimation);
		pAnimate->setDuration(duration);
		pAnimation->setRestoreOriginalFrame(false);
		return pAnimate;
	}
	return NULL;
}
开发者ID:253627764,项目名称:----Cocos2dx-MVC-,代码行数:11,代码来源:AppConfig.cpp

示例2: playShieldAnimation

int ShieldedObject::playShieldAnimation(int damage, int angle)
{
	CCAnimate* animate;
	map<int,cocos2d::CCAnimation*>::iterator it = getShieldAnimations()->find(0);
	if (it == getShieldAnimations()->end()) 
	{
		return 0;
	}
	else 
	{
		animate = CCAnimate::create(it->second);
	}
	animate->setDuration(0.13f);
	//runAction(animate);
	node->setAnchorPoint(ccp(0.5, 0.5));
	node->setRotation(angle);
	node->runAction(animate);
	return 1;
}
开发者ID:wi-secret,项目名称:TestGame,代码行数:19,代码来源:ShieldedObject.cpp

示例3: runActionWithMotion

void Animal::runActionWithMotion(MOTION motion)
{
    CCAnimation *animation	= CCAnimation::create();
	animation->setDelayPerUnit(0.1f);
    
    for( int iFrame = 0; iFrame < SPRITE_FRAME; iFrame++ )
	{
        CCTexture2D *pTexture	= animates[motion][iFrame];
        CCSize		sizeTexture = pTexture->getContentSize();
		animation->addSpriteFrameWithTexture(pTexture, CCRectMake(0, 0, sizeTexture.width, sizeTexture.height));
	}
    
	CCAnimate			*animate	= CCAnimate::create(animation);
    
    CCFiniteTimeAction	*action;
	CCPoint				direction;

	animate->setDuration(duration[motion]);

	switch(motion)
	{
	case WALK_LEFT:			
	case RUN_LEFT:			
		direction = ccp(-1.f, -1.f);	break;
	case WALK_RIGHT:		
	case RUN_RIGHT:			
		direction = ccp( 1.f, -1.f);	break;
	case WALK_BACK_LEFT:
	case RUN_BACK_LEFT:
		direction = ccp(-1.f,  1.f);	break;
	case WALK_BACK_RIGHT:
	case RUN_BACK_RIGHT:
		direction = ccp( 1.f,  1.f);	break;
	}

	switch(motion)
	{
	case WALK_LEFT:
	case WALK_RIGHT:
	case WALK_BACK_LEFT:
	case WALK_BACK_RIGHT:
		{
			CCPoint walk = ccp(direction.x*walk_scale.x, direction.y*walk_scale.y);
			action = CCSequence::actions(	
				CCSpawn::actions(CCMoveBy::create(duration[motion], walk), animate, NULL), 
				CCCallFuncN::actionWithTarget(this, callfuncN_selector(Animal::finishChk)), NULL);
		}
		break;
	case RUN_LEFT:
	case RUN_RIGHT:
	case RUN_BACK_LEFT:
	case RUN_BACK_RIGHT:
		{
			CCPoint run = ccp(direction.x*run_scale.x, direction.y*run_scale.y);
			action = CCSequence::actions(	
				CCSpawn::actions(CCMoveBy::create(duration[motion], run), animate, NULL), 
				CCCallFuncN::actionWithTarget(this, callfuncN_selector(Animal::finishChk)), NULL);
		}
		break;
	case STAND:
	case SIT:
	case SLEEP:
	case EAT:
	case POOP:
	case SICK:
	case FUN_SWING:
	case FUN_RUNNING:
	case FUN_ROPE:
		action = CCSequence::actions(	
			animate, 
			CCCallFuncN::actionWithTarget(this, callfuncN_selector(Animal::finishChk)), NULL);
		break;
	}
	motionState.name = motion;
	pBody->runAction(action);
}
开发者ID:JungHanter,项目名称:SWMTAMA,代码行数:76,代码来源:Animal.cpp


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