示例#1
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);
}
//攻击动画
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;

}
示例#4
0
void RCUnit::addSubFormWithSpriteFrameNameAndKey(const char *frameName, AnimationParam *animationParam, const char *key)
{
    //add sprite
    if (!animationParam) {
        return;
    }

    CCAnimation *animation = CCAnimationCache::sharedAnimationCache()->animationByName(key);
    if (animation == NULL) {
        animation = CCAnimation::create();

        for (int i=1; i <= animationParam->count; i++) {
            CCString *realFrameName = CCString::createWithFormat("%s%.02i.png",animationParam->frameName.c_str(),i);
            CCSpriteFrame *frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(realFrameName->getCString());
            animation->addSpriteFrame(frame);
        }
        animation->setDelayPerUnit(animationParam->interval);
        animation->setLoops(animationParam->loops);
        animation->setRestoreOriginalFrame(animationParam->restoreFirstFrame);

        CCAnimationCache::sharedAnimationCache()->addAnimation(animation, key);
    }

    m_dictionary->setObject(animation, key);
}
示例#5
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);
}
示例#6
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));
}
示例#7
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;
}
示例#8
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);
}
示例#9
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);
}
示例#10
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);
}
示例#11
0
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);
}
示例#12
0
void ASBotFightLayer::LichKingHitEnemy(){
    
    //1.移除技能粒子的飞行特效
    removeChild(skillEffect_fly);
    removeChild(blade);
    
    //2.击中特效
    CCSprite* hitEffect = CCSprite::createWithSpriteFrameName("LichKing_hit_0.png");
    hitEffect->setScale(-3);
    hitEffect->setOpacity(200);
    hitEffect->setPosition(ccp(size.width*20/50,winSize.height/2));
    addChild(hitEffect,4);
    
    CCAnimation* pAnimation = CCAnimation::create();
    for (int i = 0 ; i < 10; i++) {
        string texName = "LichKing_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);
    
    CCCallFunc* remove = CCCallFuncN::create(this, callfuncN_selector(ASBotFightLayer::removeThis));
    CCSequence* seqqq = CCSequence::create(pAnimate,remove,NULL);
    hitEffect->runAction(seqqq);
    
    //3.英雄被击中后的动作
    CCActionInterval* shake1 = CCRotateTo::create(0.15, 30);
    CCActionInterval* shake2 = CCRotateTo::create(0.15, 0);
    CCActionInterval* shake3 = CCRotateTo::create(0.15, -30);
    CCActionInterval* shake4 = CCRotateTo::create(0.15, 0);
    CCSequence* seq = CCSequence::create(shake1,shake2,shake3,shake4,NULL);
    BotHero->runAction(seq);
    
    //4.减血提示
    string damageStr = "-" + int2string(damage) + "\n" + "答错遭受额外伤害!";
    minusHP = CCLabelTTF::create(damageStr.c_str(), "Arial", 62.5);
    minusHP->setPosition(ccp(size.width*22/70, winSize.height*5.5/7));
    minusHP->setRotation(-20);
    addChild(minusHP,5);
    
    CCActionInterval* scaleDown = CCScaleTo::create(0.3,1);
    CCActionInterval* fadeOut = CCFadeOut::create(2);
    CCCallFunc* back = CCCallFuncN::create(this, callfuncN_selector(ASBotFightLayer::backToMainGame));
    CCSequence* seq1 = CCSequence::create(scaleDown,fadeOut,back,NULL);
    minusHP->runAction(seq1);
    
    CCActionInterval* flash = CCTintBy::create(0.2, -255, -91, -220);
    CCDelayTime* delay = CCDelayTime::create(0.1);
    CCActionInterval* flash1 = CCTintBy::create(0.2, 255, 91, 220);
    CCSequence* seq321 = CCSequence::create(flash,delay,flash1,NULL);
    CCRepeatForever* effect = CCRepeatForever::create(seq321);
    BotHero->runAction(effect);
}
示例#13
0
//换图片
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);
}
示例#14
0
void Hero::runFly(){
    
    CCAnimation* animation = m_nScene->createArray((char*)"jump", 3);
    animation->setLoops(-1);
    animation->setDelayPerUnit(0.01f);
    flyAction = CCAnimate::create(animation);
    flyAction->setDuration(0.9f);
    
    this->runAction(flyAction);

}
示例#15
0
void Player::setupAnimations()
{

    CCAnimation* animation;
    CCSpriteFrame * frame;
    
    //create CCAnimation object
    animation = CCAnimation::create();
    //CCString * name;
    
    frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("reload.png");
    animation->addSpriteFrame(frame);
    frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("reloadready.png");
    animation->setDelayPerUnit(.5 / 2.0f);
    animation->setRestoreOriginalFrame(false);
    _cannotReload = CCSequence::create(
                                 CCAnimate::create(animation),
                                 CCCallFuncN::create(this, callfuncN_selector(Player::canReloadAnimationDone)),
                                 NULL);
    _cannotReload->retain();
    
    animation = CCAnimation::create();
    frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("reloadready.png");
    animation->addSpriteFrame(frame);
    frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("reload.png");
    animation->setDelayPerUnit(.5 / 2.0f);
    animation->setRestoreOriginalFrame(false);
    _canReload = CCSequence::create(
                                    CCAnimate::create(animation),
                                    CCCallFuncN::create(this, callfuncN_selector(Player::cannotReloadAnimationDone)),
                                    NULL);
    _canReload->retain();
    
    //create CCAnimation object
    animation = CCAnimation::create();
    CCString * name;
    for(int i = 0; i <= 20; i++) {
        name = CCString::createWithFormat("shell%i.png", i);
        frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(name->getCString());
        animation->addSpriteFrame(frame);
    }
    
    animation->setDelayPerUnit(.5 / 21.0f);
    animation->setRestoreOriginalFrame(false);
    animation->setLoops(10);
    _rotateShells = CCSequence::create(
                                 CCAnimate::create(animation),
                                 CCCallFuncN::create(this, callfuncN_selector(Player::shellAnimationDone)),
                                 NULL);
    _rotateShells->retain();
    
}
示例#16
0
CCAnimation *MyAnimationUtil::setKomaAniByFileName2(const char *fileName1, const char *fileName2, float sec, int loop) {
	//テクスチャアトラス使う前提
	CCSpriteFrameCache *_cache = CCSpriteFrameCache::sharedSpriteFrameCache();
    
	CCArray *animFrameArr = CCArray::createWithCapacity(2);
	CCSpriteFrame *frame0 = _cache->spriteFrameByName(fileName1);
	CCSpriteFrame *frame1 = _cache->spriteFrameByName(fileName2);
	animFrameArr->addObject(frame0);
	animFrameArr->addObject(frame1);
	CCAnimation *animFrames = CCAnimation::createWithSpriteFrames(animFrameArr, sec);
	animFrames->setLoops(loop);
	return animFrames;
}
示例#17
0
SpiritMain::SpiritMain(CCLayer* layer,MainRoledata roledata,int zOrder)
{
	CCSprite* npc = SpiritMain::create(roledata.spiritUrl->getCString());
	if(npc==NULL)
	{
		CCLog("图层路径有误,请检查路径");
		return;
	}
	//设置NPC初始位置坐标(该坐标取决于当前画层)
	npc->setPosition(roledata.nowpoint);
	//NPC动画
	CCAnimation* donghua = SpiritMain::getNowAnt(roledata);
	if(roledata.actiontime>0)
	{
		donghua->setDelayPerUnit(roledata.actiontime/roledata.maxcut_zhan);
	}
	else
	{
	    donghua->setDelayPerUnit(2.0f/15.0f);//执行默认时间
	}
	donghua->setRestoreOriginalFrame(true);
	donghua->setLoops(-1);
	CCAnimate* playdonghua = CCAnimate::create(donghua);
	npc->runAction(playdonghua);
	layer->addChild(npc,zOrder); 
	//
	p_ui = new PublicShowUI();

	p_ui->setGameText(layer,roledata.spiritname,ccp(roledata.nowpoint.x,roledata.nowpoint.y+(int)(npc->getTexture()->getPixelsHigh()*0.3f)),12);

	//添加NPC人物脚下阴影
	CCSprite* yinzi = CCSprite::create(p_yinzi);
	if(yinzi==NULL)
	{
		CCLog("图层路径有误,请检查路径");
		return;
	}
	yinzi->setZOrder(0);
	yinzi->setPosition(ccp(roledata.nowpoint.x,roledata.nowpoint.y-(int)(npc->getTexture()->getPixelsHigh()*0.2f)));
	layer->addChild(yinzi);

	//添加NPC人物聊天背景
	CCSprite* sp_liaotianbd = CCSprite::create(p_liaotianbd);
	//sp_liaotianbd->setContentSize(CCSize(200,200));
	sp_liaotianbd->setZOrder(2);
	sp_liaotianbd->setPosition(ccp(roledata.nowpoint.x,roledata.nowpoint.y-(int)(npc->getTexture()->getPixelsHigh()*0.2f)));
	layer->addChild(sp_liaotianbd);


}
示例#18
0
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);
}
示例#19
0
void ASFightLayer::IronManHitEnemy(){
    
    //1.移除技能粒子的飞行特效
    removeChild(skillEffect_fly);
    removeChild(blade);
    
    //2.击中特效
    CCSprite* hitEffect = CCSprite::createWithSpriteFrameName("IronMan_hit_0.png");
    hitEffect->setScale(3.5);
    hitEffect->setOpacity(200);
    hitEffect->setPosition(ccp(size.width*35/50,winSize.height/2));
    addChild(hitEffect,4);
    
    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.2);
    pAnimation->setRestoreOriginalFrame(true);
    pAnimation->setLoops(2);
    CCAnimate* pAnimate = CCAnimate::create(pAnimation);
    
    CCCallFunc* remove = CCCallFuncN::create(this, callfuncN_selector(ASFightLayer::removeThis));
    CCSequence* seqqq = CCSequence::create(pAnimate,remove,NULL);
    hitEffect->runAction(seqqq);
    
    //3.英雄被击中后的动作
    CCActionInterval* shake1 = CCRotateTo::create(0.15, 30);
    CCActionInterval* shake2 = CCRotateTo::create(0.15, 0);
    CCActionInterval* shake3 = CCRotateTo::create(0.15, -30);
    CCActionInterval* shake4 = CCRotateTo::create(0.15, 0);
    CCSequence* seq = CCSequence::create(shake1,shake2,shake3,shake4,NULL);
    BotHero->runAction(seq);
    
    //4.减血提示
    string damageStr = "-" + int2string(damage) + "\n" + "乌云袭击!";
    minusHP = CCLabelTTF::create(damageStr.c_str(), "Arial", 62.5);
    minusHP->setScale(10);
    minusHP->setPosition(ccp(size.width*48/70, winSize.height*5/7));
    minusHP->setRotation(20);
    addChild(minusHP,5);
    
    CCActionInterval* scaleDown = CCScaleTo::create(0.3,1);
    CCActionInterval* fadeOut = CCFadeOut::create(2);
    CCCallFunc* back = CCCallFuncN::create(this, callfuncN_selector(ASFightLayer::backToMainGame));
    CCSequence* seq1 = CCSequence::create(scaleDown,fadeOut,back,NULL);
    minusHP->runAction(seq1);
}
示例#20
0
文件: Enemy.cpp 项目: ourgames/dc208
CCSequence* OutsideEnemy::createAnimation(int enemyActionStatus)
{
    CCSequence* result = nullptr;
    int totalFrame = 8;
    string actionName = "move";
    float delayPerUnit = 0.1;
    mAnimationFrameArray.clear();
    int loopTimes;
    if(enemyActionStatus == ENEMY_ACTION_STATUS_MOVE)
    {
        totalFrame = 5;
        actionName = "move";
        delayPerUnit = 0.1;
        loopTimes = numeric_limits<int>::max();
    }
    else if(enemyActionStatus == ENEMY_ACTION_STATUS_DIE)
    {
        totalFrame = 5;
        actionName = "die";
        delayPerUnit = 0.15;
        loopTimes = 1;
    }
    else if(enemyActionStatus == ENEMY_ACTION_STATUS_SCARE)
    {
        totalFrame = 7;
        actionName = "scare";
        delayPerUnit = 0.1;
        loopTimes = 1;
    }
    else if(enemyActionStatus == ENEMY_ACTION_STATUS_RETREAT)
    {
        totalFrame = 5;
        actionName = "retreat";
        delayPerUnit = 0.15;
        loopTimes = numeric_limits<int>::max();
    }
    for (int j = 0; j < totalFrame; j++)
    {
        auto cf = CCLoadSprite::getSF(CCString::createWithFormat("%s_%d_%s_%s_%d.png", mIcon.c_str(), 0, "NW", actionName.c_str(), j)->getCString());
        CC_BREAK_IF(!cf);
        mAnimationFrameArray.pushBack(cf);
    }
    CCAnimation *animation = CCAnimation::createWithSpriteFrames(mAnimationFrameArray, delayPerUnit);
    animation->setLoops(loopTimes);
    animation->setRestoreOriginalFrame(false);
    result = CCSequence::create(CCAnimate::create(animation), NULL);
    //m_iconSpr->stopAllActions();
    return result;
}
示例#21
0
文件: Player.cpp 项目: bailitusu/Pao
void Player::run() {
    CCSpriteFrame *frame = NULL;
    int picNum = 13;
    CCArray* ArrayFrame = CCArray::create();
    for (int i = 1; i<=picNum; i++) {
        frame = CCSpriteFrame::create(CCString::createWithFormat("zhujiao%d.png",i)->getCString(), CCRectMake(0, 0, 200, 200));
        ArrayFrame->addObject(frame);
    }
    
    CCAnimation* donghua = CCAnimation::createWithSpriteFrames(ArrayFrame);
    donghua->setLoops(-1);
    donghua->setDelayPerUnit(0.04f);
    CCAnimate* act = CCAnimate::create(donghua);
    getSprite()->runAction(act);
}
CCAnimation* InfoSlide3::createArray(char *name, int framCount){
    CCAnimation* animation = CCAnimation::create();
    for (int i = 0; i<framCount; i++) {
        char file[100] = {0};
        sprintf(file, "*****@*****.**" , name , i);
        animation->addSpriteFrameWithFileName(file);
    }
    
    animation->setDelayPerUnit(0.03f);
    animation->setLoops(1);
    
    return animation;
    
    
}
示例#23
0
void ASFightLayer::SheldonHitEnemyCritical(){
    removeChild(blade);
    
    //1.击中特效
    CCSprite* hitEffect = CCSprite::createWithSpriteFrameName("Sheldon_hit_0.png");
    hitEffect->setScale(6);
    hitEffect->setOpacity(200);
    hitEffect->setPosition(ccp(size.width/2,winSize.height/2));
    addChild(hitEffect,4);
    
    CCAnimation* pAnimation = CCAnimation::create();
    for (int i = 0 ; i < 7; i++) {
        string texName = "Sheldon_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);
    
    CCCallFunc* remove = CCCallFuncN::create(this, callfuncN_selector(ASFightLayer::removeThis));
    CCCallFunc* silent = CCCallFuncN::create(this, callfuncN_selector(ASFightLayer::SheldonSecondPeriodCritical));
    CCSequence* seqqq = CCSequence::create(pAnimate,remove,silent,NULL);
    hitEffect->runAction(seqqq);
    
    //2.英雄被击中后的动作
    CCActionInterval* shake1 = CCRotateTo::create(0.15, 30);
    CCActionInterval* shake2 = CCRotateTo::create(0.15, 0);
    CCActionInterval* shake3 = CCRotateTo::create(0.15, -30);
    CCActionInterval* shake4 = CCRotateTo::create(0.15, 0);
    CCSequence* seq = CCSequence::create(shake1,shake2,shake3,shake4,NULL);
    BotHero->runAction(seq);
    
    //3.减血提示
    string damageStr = "-" + int2string(damage/2);
    minusHP = CCLabelTTF::create(damageStr.c_str(), "Arial", 62.5);
    minusHP->setScale(10);
    minusHP->setPosition(ccp(size.width*48/70, winSize.height*5/7));
    minusHP->setRotation(20);
    addChild(minusHP,5);
    
    CCActionInterval* scaleDown = CCScaleTo::create(0.3,1);
    CCActionInterval* fadeOut = CCFadeOut::create(2);
    CCSequence* seq1 = CCSequence::create(scaleDown,fadeOut,NULL);
    minusHP->runAction(seq1);
}
示例#24
0
void Character::setDefaultTransform(){
    CCAnimation *animation = CCAnimation::create();
    for (int i = 1; i <= 6; i++)
    {
        std::string str = static_cast<ostringstream*>(&(ostringstream() << i))->str();
        str = "Animation/Transformation/fx0" + str + ".png";
        animation->addSpriteFrameWithFileName(str.c_str());
    }
    animation->setDelayPerUnit(0.02);
    animation->setLoops(1);
    animation->setRestoreOriginalFrame(true);
    CCAnimate *action = CCAnimate::create(animation);
    this->getSprite()->runAction(CCSequence::create(action,
                                                    CCDelayTime::create(0.08),
                                                    CCCallFuncND::create(this,callfuncND_selector(Character::setSpriteWithIDCharac),(void*)(new int(defaultID))),
                                                    NULL));
}
示例#25
0
void ASBotFightLayer::LichKingInAttackCritical(){
    
    //1.镜头向右侧移动
    CCActionInterval* moveOut = CCMoveBy::create(1, ccp(size.width*4, 0));
    CameraLayer->runAction(moveOut);
    
    //2.龙飞出
    CCPoint position[3] = {ccp(size.width*11/12,winSize.height*4.4/7),ccp(size.width*5/12,winSize.height*3.9/7),ccp(size.width*3/4,winSize.height*3.4/7)};
    float scale[3] = {0.5,0.8,1};
    for (int i = 0 ;  i < 3 ; i ++) {
        CCSprite* dragon = CCSprite::createWithSpriteFrameName("LichKing_C2_0.png");
        dragon->setScaleY(3*scale[i]);
        dragon->setScaleX(-3*scale[i]);
        dragon->setPosition(position[i]);
        addChild(dragon,2);
        
        CCAnimation* pAnimation = CCAnimation::create();
        for (int i = 0 ; i < 13; i++) {
            string texName = "LichKing_C2_" + int2string(i) + ".png";
            CCSpriteFrame* frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(texName.c_str());
            pAnimation->addSpriteFrame(frame);
        }
        pAnimation->setDelayPerUnit(0.15);
        pAnimation->setRestoreOriginalFrame(true);
        pAnimation->setLoops(1);
        
        CCDelayTime* delay1 = CCDelayTime::create(0.2);
        CCAnimate* pAnimate = CCAnimate::create(pAnimation);
        CCCallFunc* remove = CCCallFuncN::create(this, callfuncN_selector(ASBotFightLayer::removeThis));
        CCSequence* effect1 = CCSequence::create(delay1,pAnimate,remove,NULL);
        CCDelayTime* delay2 = CCDelayTime::create(0.5);
        CCActionInterval* moveBack = CCMoveBy::create(1.5, ccp(-size.width, 0));
        CCSequence* effect2 = CCSequence::create(delay2,moveBack,NULL);
        CCDelayTime* delay3 = CCDelayTime::create(1);
        if (i == 0) {
            CCCallFunc* hit = CCCallFuncN::create(this, callfuncN_selector(ASBotFightLayer::LichKingHitEnemyCritical));
            CCSequence* effect3 = CCSequence::create(delay3,hit,NULL);
            CCActionInterval* effect4 = CCSpawn::create(effect2,effect1,effect3,NULL);
            dragon->runAction(effect4);
        }else{
            CCActionInterval* effect3 = CCSpawn::create(effect1,effect2,NULL);
            dragon->runAction(effect3);
        }
    }
}
示例#26
0
CCAnimate* SpiritsPlayer::updateNowAnt(MainRoledata roledata)
{
	//NPC动画
	CCAnimation* donghua = SpiritsPlayer::getNowAnt(roledata);
	if(roledata.actiontime>0)
	{
		donghua->setDelayPerUnit(roledata.actiontime/roledata.maxcut_zhan);
	}
	else  
	{
		donghua->setDelayPerUnit(2.0f/15.0f);//执行默认时间
	}
	donghua->setRestoreOriginalFrame(true);
	donghua->setLoops(-1);
	CCAnimate* playdonghua = CCAnimate::create(donghua);

	return playdonghua;
}
示例#27
0
void Hero::startrun()
{
	if (m_animate != NULL)
	{
		stoprun();
	}
	CCAnimation *animation = CCAnimation::create();
	char namebuf[20];
	for (int i = 0; i < 15; i++)
	{
		sprintf(namebuf, "run%d.png", i + 1);
		animation->addSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(namebuf));
	}
	animation->setDelayPerUnit(0.03f);
	animation->setLoops(kCCRepeatForever);
	m_animate = CCAnimate::create(animation);
	this->runAction(m_animate);
}
示例#28
0
void ASBotFightLayer::IceCubeFall(){
    
    CCPoint position[6] = {
        ccp(size.width*3/4,winSize.height),ccp(size.width*0.4/4,winSize.height),
        ccp(size.width*2.2/4,winSize.height*3.3/7 + winSize.height/2),ccp(size.width*1.2/4, winSize.height*3.3/7+winSize.height/2),
        ccp(size.width*1.6/4, winSize.height*3.7/7 + winSize.height/2),ccp(size.width*0.8/4, winSize.height*3.7/7+winSize.height/2)};
    float scale[6] = {1,1,1.2,1.2,0.8,0.8};
    int zOrder[6] = {2,2,2,2,0,0};
    for (int i = 0 ;  i < 6 ; i ++) {
        IceCube[i] = CCSprite::createWithSpriteFrameName("LichKing_C1_0.png");
        IceCube[i]->setScaleX(-1.5*scale[i]);
        IceCube[i]->setScaleY(1.5*scale[i]);
        IceCube[i]->setPosition(position[i]);
        addChild(IceCube[i],zOrder[i]);
        
        CCAnimation* pAnimation = CCAnimation::create();
        for (int i = 0 ; i < 10; i++) {
            string texName = "LichKing_C1_" + int2string(i) + ".png";
            CCSpriteFrame* frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(texName.c_str());
            pAnimation->addSpriteFrame(frame);
        }
        pAnimation->setDelayPerUnit(0.15);
        pAnimation->setRestoreOriginalFrame(true);
        pAnimation->setLoops(-1);
        
        CCAnimate* pAnimate = CCAnimate::create(pAnimation);
        CCDelayTime* delay1 = CCDelayTime::create(0.5);
        CCActionInterval* moveBack = CCMoveBy::create(0.5, ccp(0,-winSize.height*12/20));
        if (i == 0) {
            CCSequence* effect1 = CCSequence::create(delay1,moveBack,NULL);
            CCDelayTime* delay2 = CCDelayTime::create(0.8);
            CCCallFunc* hit = CCCallFuncN::create(this, callfuncN_selector(ASBotFightLayer::IceCubeHit));
            CCSequence* effect2 = CCSequence::create(delay2,hit,NULL);
            CCActionInterval* effect3 = CCSpawn::create(pAnimate,effect1,effect2,NULL);
            IceCube[i]->runAction(effect3);
        }else{
            CCSequence* effect1 = CCSequence::create(delay1,moveBack,NULL);
            CCActionInterval* effect2 = CCSpawn::create(pAnimate,effect1,NULL);
            IceCube[i]->runAction(effect2);
        }
    }
}
示例#29
0
void TestAction::action2()
{
    CCTexture2D::PVRImagesHavePremultipliedAlpha(true);
    CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("role/pao.plist");
    Vector<CCSpriteFrame*> animFrames;
    char str[100];
    for (int i = 0; i < 5; ++i)
    {
        sprintf(str, "pao%d.png", i);
        SpriteFrame *frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(str);
        animFrames.pushBack(frame);
    }
    CCAnimation *animation = CCAnimation::createWithSpriteFrames(animFrames, 0.1f);
    animation->setLoops(-1);
    CCFiniteTimeAction *animate = CCAnimate::create(animation);
    this->runAction(animate);
    //CCSpriteFrameCache::sharedSpriteFrameCache()->removeUnusedSpriteFrames();  //使用时不会被删除,因为正在被引用
    //CCSpriteFrameCache::sharedSpriteFrameCache()->isSpriteFramesWithFileLoaded("role/pao.plist"); //检测是否有被引用
    CCSpriteFrameCache::sharedSpriteFrameCache()->removeSpriteFrameByName("role/pao.plist"); //强制删除缓存,不影响正在引用它的地方
}
示例#30
0
CCAnimation * Bomb::createAnimWithFrameNameAndNum(const char *name, int iNum, float delay, unsigned int iLoops)
{
    CCSpriteFrameCache * frameCache = CCSpriteFrameCache::sharedSpriteFrameCache();
    //frameCache-> addSpriteFramesWithFile("tank.plist","tank.png");
    int iFrameNum = iNum;
    CCSpriteFrame * frame = NULL;
    CCArray *frameArray = CCArray::create();
    for (int i=1; i<=iFrameNum; i++) {
        frame = frameCache->spriteFrameByName(CCString::createWithFormat("%s%d.png",name,i)->getCString());
        if (frame == NULL) {
            break;
        }
        frameArray->addObject(frame);
    }
    
    CCAnimation * animation = CCAnimation::createWithSpriteFrames(frameArray);
    animation->setLoops(iLoops);
    animation->setRestoreOriginalFrame(true);
    animation->setDelayPerUnit(delay);
    return animation;
}