Esempio n. 1
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();
}
Esempio n. 2
0
void GameScene::birdReadyAction()
{
    CCSize winSize =CCDirector::sharedDirector()->getWinSize();
    // 添加bird精灵
    CCSprite *bird =CCSprite::createWithSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("bird1.png"));
    bird->setPosition(ccp(winSize.width/2-80,winSize.height/2+20));
    bird->setZOrder(20);
    bird->setScale(0.6);
    bird->setTag(TAG_BIRD);
    bird->setVisible(false);
    this->addChild(bird);
    // 创建动画对象
    CCAnimation *birdAnimation =CCAnimation::create();
    birdAnimation->setDelayPerUnit(0.2);
    birdAnimation->addSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("bird1.png"));
    birdAnimation->addSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("bird2.png"));
    birdAnimation->addSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("bird3.png"));
    // 创建动画动作
    birdanimate =CCAnimate::create(birdAnimation);
    CCActionInterval *action =CCMoveBy::create(0.2,ccp(0,10));
    CCActionInterval *action1 =action->reverse();
    CCActionInterval *sequence =CCSequence::create(action,action1,NULL);
    CCSpawn *spawn =CCSpawn::create(sequence,birdanimate,NULL);
    CCRepeatForever *birdrepeatForever =CCRepeatForever::create(spawn);
    // 让bird精灵一直运行动画
    bird->runAction(birdrepeatForever);
}
Esempio n. 3
0
void GameLayer::createActions() {
    
    // Swing action for health drops
    CCFiniteTimeAction* easeSwing = CCSequence::create(CCEaseInOut::create(CCRotateTo::create(1.2f, -10), 2),
                                                       CCEaseInOut::create(CCRotateTo::create(1.2f, 10), 2),
                                                       NULL);
    
    _swingHealth = CCRepeatForever::create((CCActionInterval*)easeSwing);
    _swingHealth->retain();
    
    // Action sequence for shockwave : fade out, callback when done
    _shockwaveSequence = CCSequence::create(CCFadeOut::create(1.0f),
                                            CCCallFunc::create(this, callfunc_selector(GameLayer::shockwaveDone)),
                                            NULL);
    _shockwaveSequence->retain();
    
    // Action to grow bomb
    _growBomb = CCScaleTo::create(6.0f, 1.0);
    _growBomb->retain();
    
    // Action to rotate sprites
    CCActionInterval* rotate = CCRotateBy::create(0.5f, -90);
    _rotateSprite = CCRepeatForever::create(rotate);
    _rotateSprite->retain();
    
    // Animations
    CCAnimation* animation = CCAnimation::create();
    for (int i = 1; i <= 10; ++ i)
    {
        CCString* name = CCString::createWithFormat("boom%i.png", i);
        CCSpriteFrame* frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(name->getCString());
        animation->addSpriteFrame(frame);
    }
    
    animation->setDelayPerUnit(1 / 10.0f);
    animation->setRestoreOriginalFrame(true);
    _groundHit = CCSequence::create(CCMoveBy::create(0, ccp(0, _screenSize.height * 0.12f)),
                                    CCAnimate::create(animation),
                                    CCCallFuncN::create(this, callfuncN_selector(GameLayer::animationDone)),
                                    NULL);
    _groundHit->retain();
    
    
    animation = CCAnimation::create();
    for (int i = 1; i <=7; ++ i)
    {
        CCString* name = CCString::createWithFormat("explosion_small%i.png", i);
        CCSpriteFrame* frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(name->getCString());
        animation->addSpriteFrame(frame);
    }
    
    animation->setDelayPerUnit(0.5 / 7.0f);
    animation->setRestoreOriginalFrame(true);
    _explosion = CCSequence::create(CCAnimate::create(animation),
                                    CCCallFuncN::create(this, callfuncN_selector(GameLayer::animationDone)),
                                    NULL);
    _explosion->retain();

}
Esempio n. 4
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();
    
}
Esempio n. 5
0
void CArmySprite::addCap(void)
{
	m_pCapSprite = CCSprite::create();
	m_pCapSprite->setPosition(ccp(getContentSize().width * 0.5f, getContentSize().height * 0.5f));
	addChild(m_pCapSprite);
	CCAnimation *pAnimation = CCAnimation::create();

	char szName[128] = {0};
	//sprintf(szName, "%s%02d-%02d_0001.png", m_cName, m_sCurData.mAction, m_sCurData.mDirection);

	for (int i=0; i<ANIMATE_MAX; i++)
	{
		sprintf(szName, "%s%02d_%02d.png", "NPC_Tank", m_sCurData.mIndex, 10 + i);
		if (m_pCurCache->spriteFrameByName(szName) == NULL)
		{
			break;
		}
		pAnimation->addSpriteFrame(m_pCurCache->spriteFrameByName(szName));
	}


	pAnimation->setDelayPerUnit(0.2f);
	pAnimation->setRestoreOriginalFrame(true);

	CCAnimate *pAnimate = CCAnimate::create(pAnimation);
	CCCallFunc* pCallback = CCCallFunc::create(this, callfunc_selector(CArmySprite::openCapCall));
	CCActionInterval* pAction = (CCActionInterval*)(CCSequence::create( pAnimate,pCallback,NULL) );
	m_pCapSprite->runAction(pAction);
}
Esempio n. 6
0
void CArmySprite::runEffect(void)
{
	CCAnimation *pAnimation = CCAnimation::create();

	char szName[128] = {0};
	//sprintf(szName, "%s%02d-%02d_0001.png", m_cName, m_sCurData.mAction, m_sCurData.mDirection);

	for (int i=0; i<ANIMATE_MAX; i++)
	{
		sprintf(szName, "Explode02_%02d.png", i+1);
		if (m_pCurCache->spriteFrameByName(szName) == NULL)
		{
			break;
		}
		pAnimation->addSpriteFrame(m_pCurCache->spriteFrameByName(szName));
	}


	pAnimation->setDelayPerUnit(0.1f);
	pAnimation->setRestoreOriginalFrame(true);

	CCAnimate *pAnimate = CCAnimate::create(pAnimation);
	CCCallFunc* pCallback = CCCallFunc::create(this, callfunc_selector(CArmySprite::removeSelf));
	CCActionInterval* pAction = (CCActionInterval*)(CCSequence::create( pAnimate,pCallback,NULL) );
	m_pEffectSprite->runAction(pAction);
}
Esempio n. 7
0
void EnemyLayer::addEnemy1(float dt){
    Enemy* enemy1 = Enemy::create();
    CCAnimation *animation;
    CCAnimate* animate;
    int enemyType = rand()%3;
    switch (enemyType) {
        case 0:
            enemy1->bindSprite(CCSprite::createWithSpriteFrame(enemy1SpriteFrame),Level1, ENEMY_MAX_LIFE1);
            break;
        case 1:
            enemy1->bindSprite(CCSprite::createWithSpriteFrame(enemy2SpriteFrame),Level2, ENEMY_MAX_LIFE2);
            break;
        case 2:
            enemy1->bindSprite(CCSprite::createWithSpriteFrame(enemy3SpriteFrame_1),Level3, ENEMY_MAX_LIFE3);
            animation = CCAnimation::create();
            animation->setDelayPerUnit(0.2f);
            animation->addSpriteFrame(enemy3SpriteFrame_1);
            animation->addSpriteFrame(enemy3SpriteFrame_2);
            animate = CCAnimate::create(animation);
            enemy1->getSprite()->runAction(CCRepeatForever::create(animate));
            break;
        default:
            enemy1->bindSprite(CCSprite::createWithSpriteFrame(enemy1SpriteFrame),Level1, ENEMY_MAX_LIFE1);
            break;
    }
    this->addChild(enemy1);
    m_pAllEnemy1->addObject(enemy1);
    CCSize enemy1Size = enemy1->getContentSize();
    CCSize winSize = CCDirector::sharedDirector()->getWinSize();
    int minX = enemy1Size.width/2;
    int maxX =winSize.width -minX;
    int rangeX = maxX - minX;
    int aclX = (rand()%rangeX) + minX;
    enemy1->setPosition(ccp(aclX, winSize.height+enemy1Size.height));
    float minDuration,maxDuration;
    switch (GameLayer::getGameLevel()) {
        case EASY:
            minDuration = 3;
            maxDuration = 8;
            break;
        case NORMAL:
            minDuration = 1;
            maxDuration = 3;
            break;
        case HARD:
            minDuration = 0.5;
            maxDuration = 1;
            break;
            
        default:
            break;
    }
    int rangeDuration = maxDuration - minDuration;
    int aclDuration = (rand()%rangeDuration) + minDuration;
    CCFiniteTimeAction* moveTo = CCMoveTo::create(aclDuration, ccp(aclX, -2*enemy1Size.height));
    CCFiniteTimeAction* moveDone = CCCallFuncN::create(this, callfuncN_selector(EnemyLayer::enemyMoveFinish));
    CCSequence* sequence = CCSequence::create(moveTo,moveDone);
    enemy1->runAction(sequence);
    
}
Esempio n. 8
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);
}
Esempio n. 9
0
PlaneLayer::PlaneLayer()
{
	Layer::init();

	CCSize winSize = CCDirector::sharedDirector()->getWinSize();

	auto spriteFrameCache = cocos2d::SpriteFrameCache::sharedSpriteFrameCache(); 
	spriteFrameCache->addSpriteFramesWithFile("shoot.plist");

	auto plane = Sprite::createWithSpriteFrame(spriteFrameCache->spriteFrameByName("hero1.png"));
	plane->setPosition(ccp(winSize.width/2, plane->getContentSize().height/2));
	addChild(plane,1,PlaneSpriteTag);

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

	CCAnimation* animation = CCAnimation::create();
	animation->setDelayPerUnit(0.1);
	animation->addSpriteFrame(spriteFrameCache->spriteFrameByName("hero1.png"));
	animation->addSpriteFrame(spriteFrameCache->spriteFrameByName("hero2.png"));

	CCAnimate* animate = CCAnimate::create(animation);

	plane->runAction(blink);
	plane->runAction(CCRepeatForever::create(animate));
}
Esempio n. 10
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);
}
Esempio n. 11
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;
}
Esempio n. 12
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;				
} 						
Esempio n. 13
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);
}
Esempio n. 14
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));

}
Esempio n. 15
0
void GameScene::createBird() {
    birdID = CCRANDOM_0_1() * 3;
    
    CCString* bName = CCString::createWithFormat("bird%d_0.png", birdID);
    CCSprite* bird = CCSprite::createWithSpriteFrameName(bName->getCString());
    bird->setPosition(ccp(screenSize.width * 0.25f, screenSize.height * 0.5f));
    addChild(bird, 4, TAG_BIRD);
    
    CCAnimation* animation = CCAnimation::create();
    for (int i = 0; i < 3; i++) {
        CCString* birdName = CCString::createWithFormat("bird%d_%d.png", birdID, i);
        CCSpriteFrame* frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(birdName->getCString());
        animation->addSpriteFrame(frame);
    }
    animation->setDelayPerUnit(0.08f);
    CCAnimate* animate = CCAnimate::create(animation);
    CCRepeat* br = CCRepeat::create(animate, 2);
    
    CCMoveBy* moveUp = CCMoveBy::create(0.5f, ccp(0, -bird->getContentSize().height * 0.4f));
    CCMoveBy* moveDown = CCMoveBy::create(0.5f, ccp(0, bird->getContentSize().height * 0.4f));
    CCSequence* moveSeq = CCSequence::create(moveUp, moveDown, NULL);
    
    CCSpawn* spawn = CCSpawn::create(br, moveSeq, NULL);
    
    CCRepeatForever* repeat = CCRepeatForever::create(spawn);
    bird->runAction(repeat);
}
Esempio n. 16
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;
}
Esempio n. 17
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);
}
Esempio n. 18
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);
}
Esempio n. 19
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;
	
}
Esempio n. 20
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);
}
Esempio n. 21
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);
}
Esempio n. 22
0
bool WelcomeLayer::init()
{
	bool pRet = false;
	do 
	{
		CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("ui/shoot_background.plist");
		CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("ui/shoot.plist");

		CCSize winSize  =CCDirector::sharedDirector()->getWinSize();

		CCSprite* backGround = CCSprite::createWithSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("background.png"));
		backGround->setPosition(ccp(winSize.width/2,winSize.height/2));
		this->addChild(backGround);

		CCSprite* copyright = CCSprite::createWithSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("shoot_copyright.png"));
		copyright->setPosition(ccp(winSize.width/2,winSize.height/2));
		copyright->setAnchorPoint(ccp(0.5,0.0));
		this->addChild(copyright);

		CCSprite* loading = CCSprite::createWithSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("game_loading1.png"));
		loading->setPosition(ccp(winSize.width/2,winSize.height/2 - 10));
		this->addChild(loading);

		CCAnimation* animation = CCAnimation::create();
		animation->setDelayPerUnit(0.2f);
		animation->addSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("game_loading1.png"));
		animation->addSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("game_loading2.png"));
		animation->addSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("game_loading3.png"));
		animation->addSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("game_loading4.png"));

		CCAnimate* animate = CCAnimate::create(animation);
		CCRepeat* repeat = CCRepeat::create(animate,2);
		CCCallFuncN* repeatDone = CCCallFuncN::create(this,callfuncN_selector(WelcomeLayer::loadingDone));
		CCSequence* sequence = CCSequence::create(repeat,repeatDone,NULL);
		loading->runAction(sequence);

		this->setKeypadEnabled(true);

		getHighestHistoryScore();

		pRet = true;
	} while (0);
	return pRet;
}
Esempio n. 23
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);
}
Esempio n. 24
0
void Player::InitAnimation()
{
	CCSpriteFrameCache* cache = CCSpriteFrameCache::sharedSpriteFrameCache();

	CCAnimation* runAnim = CCAnimation::create();
	char str[64] = {0};

	//Right.
	{
		runAnim = CCAnimation::create();

		for (int i = 0; i <= 2; i++) 
		{
			sprintf(str, "move_right%d.png", i);

			CCSpriteFrame* frame = cache->spriteFrameByName(str);
			runAnim->addSpriteFrame(frame);
		}
		runAnim->setDelayPerUnit(0.04f);
		runAnim->setRestoreOriginalFrame(true);

		walk_Right_Animate = CCRepeatForever::create(CCAnimate::create(runAnim));
		walk_Right_Animate->retain();
	}

	//Up.
	{
		runAnim = CCAnimation::create();

		for (int i = 0; i <= 1; i++) 
		{
			sprintf(str, "move_up%d.png", i);

			CCSpriteFrame* frame = cache->spriteFrameByName(str);
			runAnim->addSpriteFrame(frame);
		}
		runAnim->setDelayPerUnit(0.04f);
		runAnim->setRestoreOriginalFrame(true);

		flip_Animate = CCRepeatForever::create(CCAnimate::create(runAnim));
		flip_Animate->retain();
	}
}
Esempio n. 25
0
void PlaneLayer::blowUp(int score)
{
	if (isAlive)
	{
		isAlive = false;
		this->score = score;
		CCAnimation* animation = CCAnimation::create();
		animation->setDelayPerUnit(0.2f);
		animation->addSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("hero_blowup_n1.png"));
		animation->addSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("hero_blowup_n2.png"));
		animation->addSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("hero_blowup_n3.png"));
		animation->addSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("hero_blowup_n4.png"));
		CCAnimate* animate = CCAnimate::create(animation);
		CCCallFunc* removePlane = CCCallFunc::create(this,callfunc_selector(PlaneLayer::removePlane));
		CCSequence* sequence = CCSequence::create(animate,removePlane,NULL);
		this->getChildByTag(AIRPLANE)->stopAllActions();
		this->getChildByTag(AIRPLANE)->runAction(sequence);
	}
}
Esempio n. 26
0
void Witch::playAnimation()
{
	CCAnimation* animation = CCAnimation::create();
	animation->setDelayPerUnit(0.1f);
	animation->addSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(Tex::Player_0));
	animation->addSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(Tex::Player_1));
	CCAnimate* animate = CCAnimate::create(animation);//帧动画  

	mWitch->runAction(CCRepeatForever::create(animate));

}
Esempio n. 27
0
/**
 * 更改自身面貌
 */
CCFiniteTimeAction * TFActionManager::createSelfAction(TFActionInfo &actionInfo,const CCPoint &dest)
{
	CCAnimation* animation = CCAnimation::create();
	FRAMES_ITER pos = frames.find(actionInfo.framesId);
	CCAnimate* animateAction = NULL;
	if (pos != frames.end())
	{
#define SELF_CAN_ACTION_TO 1
		std::vector<CCSpriteFrame*> &frames = pos->second.frames;
		pos->second.getFrames(frames) ;
#if (SELF_CAN_ACTION_TO)
		if (actionInfo.actionType == TFActionInfo::ACTION_ORIGIN)
#endif
		{
			for (int i = 0; i < frames.size(); i++)
			{
				animation->addSpriteFrame(frames[i]);
			}
			if (frames.empty()) return NULL;
			animation->setDelayPerUnit(actionInfo.needTime / frames.size());
			animation->setRestoreOriginalFrame(true);
			animateAction = CCAnimate::create(animation);
		}
#if (SELF_CAN_ACTION_TO)
		else if (actionInfo.actionType == TFActionInfo::ACTION_TO)
		{
			AnimateMoveAction *moveAction = AnimateMoveAction::create(actionInfo.needTime / frames.size(),dest,frames);
			return moveAction;
		}
		else if (actionInfo.actionType == TFActionInfo::ACTION_DIR)
		{
			ActionMoveDirAction * moveAction = ActionMoveDirAction::create(actionInfo.needTime / frames.size(),dest,frames,actionInfo.distance,ActionMoveDirAction::TO_DIR);
			return moveAction;
		}
		else if (actionInfo.actionType == TFActionInfo::ACTION_REVERSE_DIR)
		{
			ActionMoveDirAction * moveAction = ActionMoveDirAction::create(actionInfo.needTime / frames.size(),dest,frames,actionInfo.distance,ActionMoveDirAction::TO_REVERSE_DIR);
			return moveAction;
		}
		else if (actionInfo.actionType == TFActionInfo::ACTION_SPECIAL_ROTATE)
		{
			SkillRotateBy *roteby = SkillRotateBy::create(actionInfo.needTime,actionInfo.angle,actionInfo.anchor,actionInfo.offset);
			return roteby;
		}
		else if (actionInfo.actionType == TFActionInfo::ACTION_SPECIAL_SCALE)
		{
			SkillScaleTo *scaleTo = SkillScaleTo::create(actionInfo.needTime,actionInfo.angle,actionInfo.anchor,actionInfo.offset);
			return scaleTo;
		}	
#endif

	}
	return animateAction;
}
Esempio n. 28
0
CCAnimation * CartoonInfo::createAnimation()
{
	CCAnimation* animation = CCAnimation::create();
	for (int i = 0; i < frames.size(); i++)
	{
		animation->addSpriteFrame(frames[i]);
	}
	if (frames.empty()) return NULL;
	animation->setDelayPerUnit(needTime / frames.size());
	animation->setRestoreOriginalFrame(true);
	return animation;
}
bool PlayerPlaneLayer::init(BulletLayer* bullet)
{
    if (PlaneLayer::init(e_pt_player, bullet))
    {
        // animation
        CCAnimation* animation = CCAnimation::create();
        animation->setDelayPerUnit(0.5f);
        animation->addSpriteFrame(CCSpriteFrame::create("plane.png", CCRectMake(0, 0, 40, 43)));
        animation->addSpriteFrame(CCSpriteFrame::create("plane2.png", CCRectMake(0, 0, 40, 43)));
        CCAnimate* animate = CCAnimate::create(animation);
        m_spPlane->runAction(CCRepeatForever::create(animate));
        
        // touch
        this->setTouchEnabled(true);
        
        // fire!
        fire();
        
//        // blood
//        CCSprite * spBloodBG = CCSprite::create("blood_bg.png");
//        if (spBloodBG)
//        {
//            spBloodBG->setAnchorPoint(ccp(0,1));
//            spBloodBG->setPosition(ccp(getWinSize().width - 20 - 238, getWinSize().height - 30));
//            this->addChild(spBloodBG);
//        }
//        
//        m_spBlood = CCSprite::create("blood_red.png");
//        if (m_spBlood)
//        {
//            m_spBlood->setAnchorPoint(ccp(0,1));
//            m_spBlood->setPosition(ccp(getWinSize().width - 20 - 238, getWinSize().height - 30));
//            this->addChild(m_spBlood);
//        }
        
        return true;
    }
    
    return false;
}
Esempio n. 30
0
CCAnimation* AnimationManager::createBobOnNormalBoardLeftAnimation(){
	CCAnimation *animation;
	animation = CCAnimation::create();
	CCSpriteFrame *frame;
	CCString *name;
	for(int i = 0; i < 3; ++i){
		name = CCString::createWithFormat("bob_walk_left_%i.png",i);
		frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(name->getCString());
		animation->addSpriteFrame(frame);
	}
	animation->setDelayPerUnit(0.1f);
	return animation;
}