Example #1
0
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;
}
CCAnimation* AnimationUtil::createAnimWithSingleFrameN( const char* name, float delay, unsigned int iLoops) {
    CCSpriteFrameCache* cache = CCSpriteFrameCache::sharedSpriteFrameCache();

    CCArray* framesArray = CCArray::create();

    CCSpriteFrame* frame = NULL;
    int index = 1;
    do {
        frame = cache->spriteFrameByName(CCString::createWithFormat("%s%d.png", name, index++)->getCString());

        /* 不断地获取CCSpriteFrame对象,直到获取的值为NULL */
        if(frame == NULL) {
            break;
        }

        framesArray->addObject(frame);
    }while(true);

    CCAnimation* animation = CCAnimation::createWithSpriteFrames(framesArray);
    animation->setLoops(iLoops);
    animation->setRestoreOriginalFrame(true);
    animation->setDelayPerUnit(delay);

    return animation;
}
Example #3
0
	void LoadScene::onEnter()
	{
		CScene::onEnter();
		CSVFile* file = (CSVFile*)FileUtils::sharedFileUtils()->loadCSVFile(CSV_ROOT("preloadRes.csv"));
		schedule(schedule_selector(LoadScene::loadResource));

		//进度条
		mProgress = (CProgressBar*)m_ui->findWidgetById("progress");
		mProgress->setMaxValue(100);

		//僵尸跳
		CCAnimation *pZombieEffect = AnimationManager::sharedAction()->getAnimation("9049");
		pZombieEffect->setDelayPerUnit(0.05f);
		CCAnimate* pAnimate = CCAnimate::create(pZombieEffect);
		CCSprite* pZombieSprite = CCSprite::create();
		pZombieSprite->setScale(0.9f);
		pZombieSprite->setAnchorPoint(ccp(0.5f, 0.0f));
		pZombieSprite->setPositionY(mProgress->getPositionY()+5);
		m_ui->addChild(pZombieSprite);
		pZombieSprite->runAction(CCRepeatForever::create(pAnimate));
		m_pZombieSprite = pZombieSprite;

		CCSprite* tBackround = (CCSprite*)m_ui->findWidgetById("bg");
		tBackround->initWithFile("warScene/LoadImage/1.png");			//容错性处理
	}
Example #4
0
void Trooper::animate(const char* animationName, ...){
	va_list params;
	va_start(params, animationName);
	const char* nextName = animationName;
	if (m_current_sprite != NULL && m_animate_action != NULL){
		m_current_sprite->stopAction(m_animate_action);
		m_animate_action = NULL;
	}
	CCArray* animations = CCArray::array();

	while (nextName){
		CCAnimation* anim = TFAnimationCache::sharedAnimationCache()->animationByName(nextName);
		if (m_current_sprite == NULL){
			m_current_sprite = CCSprite::spriteWithSpriteFrame(anim->getFrames()->getObjectAtIndex(0));
			this->addChild(m_current_sprite);
		}
		CCCallFuncO* notifyAction = CCCallFuncO::actionWithTarget(this, callfuncO_selector(Trooper::onAnimationStart), new CCString(nextName));
		animations->addObject(notifyAction);
		nextName = va_arg(params, const char*);
		if (nextName == NULL){
			CCCallFuncO* animAction = CCCallFuncO::actionWithTarget(this, callfuncO_selector(Trooper::animateForever), anim);
			animations->addObject(animAction);
			animAction->retain();
		} else {
			animations->addObject(CCAnimate::actionWithAnimation(anim));
		}
		notifyAction->retain();
	}
	m_current_sprite->runAction(CCSequence::actionsWithArray(animations));
	va_end(params);
	animations->retain();
}
Example #5
0
bool PlaneLayer::init()
{
	bool bRet = false;
	do
	{
		CC_BREAK_IF(!CCLayer::init());
		CCSize winSize = CCDirector::sharedDirector()->getWinSize();
		//CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("ui/shoot.plist");
		CCSprite* plane = CCSprite::createWithSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("hero1.png"));
		plane->setPosition(ccp(winSize.width/2,plane->getContentSize().height/2));
		this->addChild(plane,0,AIRPLANE);

		CCBlink* blink = CCBlink::create(1,3);

		CCAnimation* animation = CCAnimation::create();
		animation->setDelayPerUnit(0.1f);
		animation->addSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("hero1.png"));
		animation->addSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("hero2.png"));
		CCAnimate* animate = CCAnimate::create(animation);

		plane->runAction(blink);
		plane->runAction(CCRepeatForever::create(animate));

		bRet = true;
	} while (0);
	return bRet;
	
}
Example #6
0
//-----------------------------------------------------------------------------
//todo 预载入资源,实现StartScene后将其删除
void CGameScene::preloadResources()
{
	CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("fishingjoy_resource.plist");

	//以下代码创建了两个不同的动画帧序列,使用时获取动画可以这么做:CCAnimation* animation = CCAnimationCache::sharedAnimationCache()->animationByName(const char* name);
	int frameCount = STATIC_DATA_INT("fish_frame_count");
	for (int type = k_Fish_Type_Red; type < k_Fish_Type_Count; type++)
	{
		//以下代码会创建animation失败
// 		CCAnimation* fishAnimation = CCAnimation::create();
// 		for (int i = 0; i < frameCount; i++)
// 		{
// 			fishAnimation->addSpriteFrameWithFileName(
// 				CCString::createWithFormat(STATIC_DATA_STRING("fish_frame_name_format"), type, i)->getCString());
// 		}

		CCArray* spriteFramesArray = CCArray::createWithCapacity(frameCount);
		for (int i = 0; i < frameCount; i++)
		{
			CCString* fileName = CCString::createWithFormat(STATIC_DATA_STRING("fish_frame_name_format"), type, i);
			CCSpriteFrame* spriteFrame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(fileName->getCString());
			spriteFramesArray->addObject(spriteFrame);
		}
		CCAnimation* fishAnimation = CCAnimation::createWithSpriteFrames(spriteFramesArray);
		fishAnimation->setDelayPerUnit(STATIC_DATA_FLOAT("fish_frame_delay"));		
		CCString* animationName = CCString::createWithFormat(STATIC_DATA_STRING("fish_animation"),type);
		CCAnimationCache::sharedAnimationCache()->addAnimation(fishAnimation, animationName->getCString());
	}

	
}
}

CCAction* HelloWorld::createAction(int begin,int end,char* cacheActionName,CCPoint point){
	CCAnimationCache *animCache = CCAnimationCache::sharedAnimationCache();
	CCArray *array = CCArray::createWithCapacity(end-begin);

	char name[20];
	for(int i = begin ;i<end;i++){
		sprintf(name,"A1_%d.png",i);
		CCSpriteFrame* frame =cache->spriteFrameByName(name);
		array->addObject(frame);
	}

	CCAnimation *plistAnimation = CCAnimation::createWithSpriteFrames(array,0.2f);
	CCAnimationCache::sharedAnimationCache()->addAnimation(plistAnimation, cacheActionName);

	array->removeAllObjects();

	CCAnimation *animation = animCache->animationByName(cacheActionName);
	animation->setRestoreOriginalFrame(true);
	CCAnimate *ani=CCAnimate::create(animation);
	CCActionInterval* plistSeq=(CCActionInterval*)(CCSequence::create(ani,
		CCFlipX::create(point.x>0? true:false),
		ani->copy()->autorelease(),
		NULL
	));
//攻击动画
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;

}
//怪物走动的动画
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;

}
Example #10
0
void Planet::slowDown()
{
	// 当前的逻辑禁止在一个减速期间叠加另一个减速
	if(m_bSlowDowned)
		return;

	m_bSlowDowned = true;	

	if(!m_pSlowDownMark)
	{
		setSlowDownMark(CCSprite::create());
		m_pSlowDownMark->setPosition(ccp(113,65));
		this->addChild(m_pSlowDownMark);
	}

	m_pSlowDownMark->setVisible(true);	

	CCSpriteFrameCache* cache = CCSpriteFrameCache::sharedSpriteFrameCache();
	cache->addSpriteFramesWithFile("SlowDownMark.plist");
	CCAnimation* animation = CCAnimation::create();
	animation->addSpriteFrame(cache->spriteFrameByName("SlowDownMark_0.png"));	
	animation->addSpriteFrame(cache->spriteFrameByName("SlowDownMark_1.png"));	
	animation->addSpriteFrame(cache->spriteFrameByName("SlowDownMark_2.png"));	
	animation->addSpriteFrame(cache->spriteFrameByName("SlowDownMark_3.png"));	
	animation->addSpriteFrame(cache->spriteFrameByName("SlowDownMark_4.png"));	
	animation->addSpriteFrame(cache->spriteFrameByName("SlowDownMark_4.png"));
	animation->setDelayPerUnit(0.2f);
	CCAnimate* animate = CCAnimate::create(animation);
	m_pSlowDownMark->runAction(CCRepeatForever::create(animate));	

	this->scheduleOnce(schedule_selector(Planet::slowDownRestore) , SLOW_DOWN_DURATION);

	if(m_pFace)
		m_pFace->cry();
}
Example #11
0
void ASBot::botisGangLied(){
    
    CCSprite* ani = CCSprite::createWithSpriteFrameName("Miku_GL_0.png");
    ani->setRotation(-90);
    ani->setScale(2);
    ani->setPosition(ccp(size.width*5/40,size.height*80.3/90+winDif*2*alpha*alpha));
    player1->addChild(ani,100);
    
    CCAnimation* pAnimation = CCAnimation::create();
    for (int i = 0 ; i < 16; i++) {
        string texName = "Miku_GL_" + int2string(i) + ".png";
        CCSpriteFrame* frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(texName.c_str());
        pAnimation->addSpriteFrame(frame);
    }
    pAnimation->setDelayPerUnit(0.1);
    pAnimation->setRestoreOriginalFrame(true);
    pAnimation->setLoops(1);
    
    CCAnimate* pAnimate = CCAnimate::create(pAnimation);
    CCActionInterval* attack = CCMoveBy::create(1.8, ccp(size.width*30/40,0));
    CCActionInterval* effect = CCSpawn::create(pAnimate,attack,NULL);
    CCCallFunc* remove = CCCallFuncN::create(player1, callfuncN_selector(ASGame::removeSprite));
    CCCallFunc* add = CCCallFuncN::create(this, callfuncN_selector(ASBot::botMinusHpByGangLie));
    CCSequence* seq = CCSequence::create(effect,remove,add,NULL);
    
    ani->runAction(seq);
}
Example #12
0
void UICenterItem::startProcess()
{
	valid = false;
	// 创建一个动画 自身播放时间到后将valid 设置为true
	CCAnimation* animation = CCAnimation::create();
		std::string frameNames[] = {
			std::string("skill_p_00000.png"),
			std::string("skill_p_00001.png"),
			std::string("skill_p_00002.png"),
			std::string("skill_p_00003.png"),
			std::string("skill_p_00004.png"),
			std::string("skill_p_00005.png"),
		};
	for (int i = 0; i < 3; i++)
	{
		CCTexture2D *texture = CCTextureCache::sharedTextureCache()->addImage(frameNames[i].c_str());
		
		CCSpriteFrame *frame = CCSpriteFrame::frameWithTexture(texture,CCRectMake(0,0,texture->getContentSize().width,texture->getContentSize().height));
		
		animation->addSpriteFrame(frame);
	}
	CCSprite * temp = CCSprite::create();
	this->getParent()->addChild(temp);
	temp->setPosition(this->getPosition());
	animation->setDelayPerUnit(1.5f / 2);
	animation->setRestoreOriginalFrame(true);
	temp->runAction(CCSequence::create(CCAnimate::create(animation),
		CCCallFuncND::create(this, callfuncND_selector(UICenterItem::actionEnd_setValid), (void*)temp),NULL));

}
Example #13
0
void CSmeltArmor::initFire()
{
	//获取参考位置
	CCNode* pNode = (CCNode*)m_ui->findWidgetById("fire_circle");
	CCPoint pPos = ccp(pNode->getPositionX()+15, pNode->getPositionY()+75);

	if(m_pFire1 == nullptr)
	{
		CCAnimation* pAnimation = AnimationManager::sharedAction()->getAnimation("9010");
		pAnimation->setDelayPerUnit(0.15f);
		m_pFire1 = CCSprite::create("skill/9010.png");
		m_pFire1->setPosition(pPos);
		m_pFire1->runAction(CCRepeatForever::create(CCAnimate::create(pAnimation)));
		m_pFire1->setVisible(false);
		m_pFire1->setScale(1.6f);
		pNode->getParent()->addChild(m_pFire1, pNode->getZOrder());
	}
	if(m_pFire2 == nullptr)
	{
		CCAnimation* pAnimation = AnimationManager::sharedAction()->getAnimation("9011");
		pAnimation->setDelayPerUnit(0.15f);
		m_pFire2 = CCSprite::create("skill/9011.png");
		m_pFire2->setPosition(pPos);
		m_pFire2->runAction(CCRepeatForever::create(CCAnimate::create(pAnimation)));
		m_pFire2->setVisible(false);
		m_pFire2->setScale(1.5f);
		pNode->getParent()->addChild(m_pFire2, pNode->getZOrder());
	}
}
Example #14
0
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;
}
Example #15
0
void ASFightLayer::SheldonSecondPeriodCritical(){
    
    //1.击中特效
    CCSprite* hitEffect = CCSprite::createWithSpriteFrameName("Sheldon_C2_0.png");
    hitEffect->setScale(2);
    hitEffect->setPosition(ccp(size.width*2/3,winSize.height/2));
    addChild(hitEffect,4);
    
    CCAnimation* pAnimation = CCAnimation::create();
    for (int i = 0 ; i < 24; i++) {
        string texName = "Sheldon_C2_" + int2string(i) + ".png";
        CCSpriteFrame* frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(texName.c_str());
        pAnimation->addSpriteFrame(frame);
    }
    pAnimation->setDelayPerUnit(0.1);
    pAnimation->setRestoreOriginalFrame(true);
    pAnimation->setLoops(1);
    
    CCAnimate* pAnimate = CCAnimate::create(pAnimation);
    CCCallFunc* remove = CCCallFuncN::create(this, callfuncN_selector(ASFightLayer::removeThis));
    CCSequence* effect1 = CCSequence::create(pAnimate,remove,NULL);
    CCDelayTime* delay = CCDelayTime::create(1.5);
    CCCallFunc* hit = CCCallFuncN::create(this, callfuncN_selector(ASFightLayer::SheldonSecondHitEnemy));
    CCSequence* effect2= CCSequence::create(delay,hit,NULL);
    CCActionInterval* effect3 = CCSpawn::create(effect1,effect2,NULL);
    hitEffect->runAction(effect3);
}
Example #16
0
void ASBotFightLayer::BladeMasterPreAttack(){
    
    CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("bmattack.mp3", false);
    
    //1.英雄身上闪光
    CCActionInterval* flash = CCTintBy::create(0.2, -3, -198, -213);
    CCDelayTime* delay = CCDelayTime::create(0.1);
    CCActionInterval* flash1 = CCTintBy::create(0.2, 3, 198, 213);
    CCSequence* seq = CCSequence::create(flash,delay,flash1,NULL);
    CCRepeatForever* effect = CCRepeatForever::create(seq);
    MainHero->runAction(effect);
    
    //2.蓄力动画
    blade = CCSprite::createWithSpriteFrameName("Blade_0_0.png");
    blade->setRotation(-90);
    blade->setScaleY(2);
    blade->setScaleX(-1.2);
    blade->setOpacity(100);
    blade->setPosition(ccp(size.width*21/50,winSize.height/2));
    addChild(blade,3);
    
    CCAnimation* pAnimation = CCAnimation::create();
    for (int i = 0 ; i < 6; i++) {
        string texName = "Blade_0_" + int2string(i) + ".png";
        CCSpriteFrame* frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(texName.c_str());
        pAnimation->addSpriteFrame(frame);
    }
    pAnimation->setDelayPerUnit(0.1);
    pAnimation->setRestoreOriginalFrame(true);
    pAnimation->setLoops(-1);
    CCAnimate* pAnimate = CCAnimate::create(pAnimation);
    
    blade->runAction(pAnimate);
}
Example #17
0
//! 在此层中管理enemy的运动 爆炸 移除 和添加
bool LayerEnemy::init() 			
{ 						
	CCLayer::init(); 			

	m_psmallArray = CCArray::create();
	CC_SAFE_RETAIN(m_psmallArray);
	m_psmallArray->retain();
	m_psmallArray->autorelease();

	//! 缓存爆炸动画
	CCAnimation *smallAnimation = CCAnimation::create();
	smallAnimation->setDelayPerUnit(0.1f);
	char nameBuf[100];
	for (int i = 0; i < 4; i++)
	{
		memset(nameBuf, 0, sizeof(nameBuf));
		sprintf(nameBuf, "enemy1_down%d.png", i + 1);
		smallAnimation->addSpriteFrame
			(CCSpriteFrameCache::sharedSpriteFrameCache()
			->spriteFrameByName(nameBuf));
	}
	CCAnimationCache::sharedAnimationCache()->addAnimation(smallAnimation, "SmallBlowUp");

	schedule(schedule_selector(LayerEnemy::addSmallEnemy), 0.5f);

	return true;				
} 						
Example #18
0
 void HelloWorld::GenerateHulkAnimation(char *Name,int Max,cocos2d::CCSprite* sp)
 {
	 char *frameName = new char[1024];
	 cocos2d::CCAnimate *_curAnimate;
	 CCAnimation* animaiton = CCAnimation::create();

	 for(int i = 1; i <= Max; ++i){

		 sprintf(frameName, "%s%d.png", Name, i);
		 animaiton->addSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(frameName)); 



	 }
	 for(int i = 1; i <= Max; ++i){

		 animaiton->addSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(frameName)); 

	 }
	 animaiton->setDelayPerUnit(0.1);
	 _curAnimate = CCAnimate::create(animaiton);
	 //CCActionInterval*   action =   CCAnimate::actionWithDuration(1);
	 //CCRepeatForever*    repeatAction   =   CCRepeatForever::actionWithAction(action);

	 //sp->runAction(repeatAction);
	 sp->runAction(_curAnimate);
		
       
}
Example #19
0
CCAnimation* GameObject::loadPlistForAnimationWithName(CCString* animationName, CCString* className){
    
    CCAnimation *animationToReturn = CCAnimation::create();
    CCSpriteFrame *frame;
    CCString *frameName;
    
    CCDictionary *plist = CCDictionary::createWithContentsOfFile(CCString::createWithFormat("%s.plist",className->getCString())->getCString());
    CCDictionary *anim = (CCDictionary*)plist->objectForKey(animationName->getCString());
    CCString *fileNamePrefix = (CCString*)anim->objectForKey("fileNamePrefix");
    CCString *delay = (CCString*)anim->objectForKey("delay");
    CCString *animationFrames = (CCString*)anim->objectForKey("animationFrames");
    
    std::vector<int> vect;
    
    std::stringstream ss(animationFrames->getCString());
    int i;
    
    while (ss >> i)
    {
        vect.push_back(i);
         
        if (ss.peek() == ',')
            ss.ignore();
    }

    for (vector<int>::size_type i = 1; i <= vect.size(); ++i)
    {
        frameName = CCString::createWithFormat("%s%i.png",fileNamePrefix->getCString(),i);
        frame= CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(frameName->getCString());
        animationToReturn->addSpriteFrame(frame);
    }
    animationToReturn->setDelayPerUnit(delay->floatValue());
    return animationToReturn;
}
Example #20
0
 void HelloWorld::runNamasteAnimation(CCObject* pSender)
{
	SimpleAudioEngine::sharedEngine()->playEffect("angrypunch.mp3");
    //GenerateHulkAnimation("namaste_1_",4,hulk);
	cocos2d::CCAnimate *_curAnimate;
	CCAnimation* animaiton = CCAnimation::create();

	for(int i = 1; i <= 4; ++i){
	char *frameName = new char[1024];
	sprintf(frameName, "%s%d.png", "namaste_1_", i);
	animaiton->addSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(frameName)); 
		


	}
	for(int i = 1; i <= 8; ++i){
	
		animaiton->addSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("namaste_1_4.png")); 
	
	}
		animaiton->setDelayPerUnit(0.1);
		_curAnimate = CCAnimate::create(animaiton);
		// CCActionInterval*   action =   CCAnimate::actionWithDuration(1);
		//CCRepeatForever*    repeatAction   =   CCRepeatForever::actionWithAction(action);

		//sp->runAction(repeatAction);
		hulk->runAction(_curAnimate);
	
}
Example #21
0
void BlockManager::loadResource()
{
    CHAR szTemp[128] = {0};
    CCAnimation* Ani = new CCAnimation;

    m_pBgaSprite = CCSprite::spriteWithTexture(ResourceManager::sharedManager()->getMap(67));
    m_pBgaSprite->setAnchorPoint(ccp(0,0));
    m_pBgaSprite->setPosition(ccp(-1000,-1000));
    m_pGround->addChild(m_pBgaSprite);

    Ani->initWithName("TILE");

    for(int i=0; i<6; i++)
    {
        sprintf_s(szTemp, "Tile/Tile_Ground_%d.png",i);
        Ani->addFrameWithFileName(szTemp);
    }

    m_pBlockSprite = new CCSprite;
    m_pBlockSprite->init();
    m_pBlockSprite->setAnchorPoint(ccp(0,0));
    m_pBlockSprite->addAnimation(Ani);
    m_pBlockSprite->setIsVisible(false);
    m_pBlockSprite->setPosition(ccp(-1000,-1000));
    m_pGround->addChild(m_pBlockSprite);

    m_bLoaded = true;
    m_bLook	 = false;

    m_pBlock = new Object_block;
    m_pBlock->initWithBlock();
}
Example #22
0
void CSharpTollgate::onEnter()
{
	BaseLayer::onEnter();

	CButton* pClose = CButton::create("common/back.png", "common/back.png");
	pClose->getSelectedImage()->setScale(1.1f);
	pClose->setPosition(VLEFT+50, VTOP-50);
	pClose->setOnClickListener(this,ccw_click_selector(CSharpTollgate::onClose));
	this->addChild(pClose, 999);


	m_cell = (CLayout*)(m_ui->findWidgetById("Cell"));
// 	m_cell->retain();
// 	m_ui->removeChild(m_cell);

	
	CCAnimation *bgAnim = AnimationManager::sharedAction()->getAnimation("8055");
	bgAnim->setDelayPerUnit(0.05f);
	CCSprite *bg = createAnimationSprite("skill/8055.png",VCENTER,bgAnim,true);
	bg->setScale(3.0f);
	m_ui->addChild(bg);

	m_tableView = (CTableView *)(m_ui->findWidgetById("scroll"));
	m_tableView->setDirection(eScrollViewDirectionHorizontal);
	m_tableView->setSizeOfCell(m_cell->getContentSize());
	//m_tableView->setSizeOfCell(CCSizeMake(790,115));
	m_tableView->setCountOfCell(0);
	m_tableView->setBounceable(false);
	m_tableView->setDataSourceAdapter(this,ccw_datasource_adapter_selector(CSharpTollgate::tableviewDataSource));	
	m_tableView->reloadData();

}
void ASBotFightLayer::SwordFall(){
    
    sword = CCSprite::createWithSpriteFrameName("LichKing_C3_0.png");
    sword->setScaleX(-7);
    sword->setScaleY(7);
    sword->setPosition(ccp(size.width*3/7, winSize.height*6/7));
    addChild(sword,2);
    
    CCAnimation* pAnimation = CCAnimation::create();
    for (int i = 0 ; i < 24; i++) {
        string texName = "LichKing_C3_" + int2string(i) + ".png";
        CCSpriteFrame* frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(texName.c_str());
        pAnimation->addSpriteFrame(frame);
    }
    pAnimation->setDelayPerUnit(0.14);
    pAnimation->setRestoreOriginalFrame(true);
    pAnimation->setLoops(-1);
    
    CCAnimate* pAnimate = CCAnimate::create(pAnimation);
    CCDelayTime* delay = CCDelayTime::create(2);
    CCActionInterval* moveDown = CCMoveBy::create(0.5, ccp(0, -winSize.height*11/20));
    CCSequence* effect1 = CCSequence::create(delay,moveDown,NULL);
    CCDelayTime* delay1 = CCDelayTime::create(2.3);
    CCCallFunc* hit = CCCallFuncN::create(this, callfuncN_selector(ASBotFightLayer::LichKingBigAttack));
    CCSequence* effect2 = CCSequence::create(delay1,hit,NULL);
    CCActionInterval* effect3 = CCSpawn::create(pAnimate,effect1,effect2,NULL);
    
    sword->runAction(effect3);
}
Example #24
0
void RoleJoyPad::initAction()
{
    //元素动作数组
    m_actionArray = CCArray::createWithCapacity(5);
    m_actionArray->retain();
    
    char fileName1[64] = {0};
    char fileName2[64] = {0};
    char fileName3[64] = {0};

    for (int i = 1; i != 6; ++i)
    {
        sprintf(fileName1, "item_%d_3.png", i);
        sprintf(fileName2, "item_%d_4.png", i);
        sprintf(fileName3, "item_%d_5.png", i);
        
        CCSpriteFrame* frame1 = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(fileName1);
        CCSpriteFrame* frame2 = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(fileName2);
        CCSpriteFrame* frame3 = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(fileName3);
        
        //消除帧动画
        CCAnimation* animation = CCAnimation::create();
        animation->addSpriteFrame(frame1);
        animation->addSpriteFrame(frame2);
        animation->addSpriteFrame(frame3);
        animation->setDelayPerUnit(0.3f/3);
        animation->setRestoreOriginalFrame(false);
        CCAnimate* animate = CCAnimate::create(animation);
        
        CCSpawn* animate_action = CCSpawn::create(animate, CCMoveBy::create(0.15f, ccp(0, 30)), NULL);
        
        m_actionArray->addObject(animate_action);
    }
}
Example #25
0
void ASFightLayer::IronManPreAttack(){
    
    if(!MainUser->muted)
        CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("ironmanattack.mp3");
    
    //1.英雄身上闪光
    CCActionInterval* flash = CCTintBy::create(0.2, -3, -198, -213);
    CCDelayTime* delay = CCDelayTime::create(0.1);
    CCActionInterval* flash1 = CCTintBy::create(0.2, 3, 198, 213);
    CCSequence* seq = CCSequence::create(flash,delay,flash1,NULL);
    CCRepeatForever* effect = CCRepeatForever::create(seq);
    MainHero->runAction(effect);
    
    //2.蓄力动画
    blade = CCSprite::createWithSpriteFrameName("IronMan_hit_0.png");
    blade->setOpacity(100);
    blade->setPosition(ccp(size.width*19/50,winSize.height*9.8/20));
    addChild(blade,3);
    
    CCAnimation* pAnimation = CCAnimation::create();
    for (int i = 0 ; i < 4; i++) {
        string texName = "IronMan_hit_" + int2string(i) + ".png";
        CCSpriteFrame* frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(texName.c_str());
        pAnimation->addSpriteFrame(frame);
    }
    pAnimation->setDelayPerUnit(0.1);
    pAnimation->setRestoreOriginalFrame(true);
    pAnimation->setLoops(-1);
    CCAnimate* pAnimate = CCAnimate::create(pAnimation);
    
    blade->runAction(pAnimate);
}
Example #26
0
bool GridNode::init() {
    bool bRet = false;
    do {
        CCNode::init();
        this->setContentSize(CCSize(GRID_WIDTH, GRID_HEIGHT));

        m_gridSprite = CCSprite::create();
        m_gridSprite->setAnchorPoint(CCPoint(0.5, 0.5));
        m_gridSprite->setPosition(CCPoint(GRID_WIDTH / 2, GRID_HEIGHT / 2));
        this->addChild(m_gridSprite, 10);

        m_animSprite = CCSprite::create();
        m_animSprite->setAnchorPoint(CCPoint(0.5, 0.5));
        m_animSprite->setPosition(CCPoint(GRID_WIDTH / 2, GRID_HEIGHT / 2));
        m_animSprite->setVisible(false);
        this->addChild(m_animSprite, 0);

        CCAnimation* selectAnimatoin = CCAnimation::create();
        CCString* frame;
        for (int i = 0; i < 5; i++) {
            frame = CCString::createWithFormat("select_frame_%d.png", i);
            selectAnimatoin->addSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(frame->getCString()));
        }
        selectAnimatoin->setDelayPerUnit(0.5f / 5.0f);
        selectAnimatoin->setLoops(true);
        m_selectAnimate = CCRepeatForever::create(CCAnimate::create(selectAnimatoin));
        m_selectAnimate->setTag(SELECT_ACTION_TAG);
        m_selectAnimate->retain();

        bRet = true;
    } while (0);

    return bRet;
}
Example #27
0
CCAnimation* CCAnimation::animationWithAnimationFrames(CCArray* arrayOfSpriteFrameNames, float delayPerUnit, unsigned int loops)
{
    CCAnimation *pAnimation = new CCAnimation();
    pAnimation->initWithAnimationFrames(arrayOfSpriteFrameNames, delayPerUnit, loops);
    pAnimation->autorelease();
    return pAnimation;
}
Example #28
0
void ASFightLayer::SheldonPreAttackCritical(){
    //1.英雄身上闪光
    CCActionInterval* flash = CCTintBy::create(0.2, -3, -198, -213);
    CCDelayTime* delay = CCDelayTime::create(0.1);
    CCActionInterval* flash1 = CCTintBy::create(0.2, 3, 198, 213);
    CCSequence* seq = CCSequence::create(flash,delay,flash1,NULL);
    CCRepeatForever* effect = CCRepeatForever::create(seq);
    MainHero->runAction(effect);
    
    //2.蓄力动画
    blade = CCSprite::createWithSpriteFrameName("Sheldon_0_0.png");
    blade->setScaleY(2.5);
    blade->setScaleX(-2.5);
    blade->setPosition(ccp(size.width*50/50,winSize.height*45/70));
    addChild(blade,3);
    
    CCAnimation* pAnimation = CCAnimation::create();
    for (int i = 0 ; i < 17; i++) {
        string texName = "Sheldon_0_" + int2string(i) + ".png";
        CCSpriteFrame* frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(texName.c_str());
        pAnimation->addSpriteFrame(frame);
    }
    pAnimation->setDelayPerUnit(0.14);
    pAnimation->setRestoreOriginalFrame(true);
    pAnimation->setLoops(-1);
    CCAnimate* pAnimate = CCAnimate::create(pAnimation);
    
    blade->runAction(pAnimate);
}
Example #29
0
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());
}
Example #30
0
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));
}