Пример #1
0
void GameObjHero::onEnter()
{
    CCNode::onEnter();
    this->setContentSize(CCSizeMake(85, 90));
    CCDirector *pDirector = CCDirector::sharedDirector();
    pDirector->getTouchDispatcher()->addTargetedDelegate(this, 0, true);
    CCSprite *obj = CCSprite::create("s_hurt.png");
    hurt = obj->getTexture();
    obj = CCSprite::create("s_jump.png");
    jump = obj->getTexture();
    mainsprite = CCSprite::create("s_1.png");
    //动画
    CCAnimation *animation = CCAnimation::create();
    animation->addSpriteFrameWithFileName("s_1.png");
    animation->addSpriteFrameWithFileName("s_2.png");
    animation->addSpriteFrameWithFileName("s_3.png");
    animation->addSpriteFrameWithFileName("s_4.png");
    animation->addSpriteFrameWithFileName("s_5.png");
    animation->addSpriteFrameWithFileName("s_6.png");
    animation->setDelayPerUnit(0.1f);
    animation->setRestoreOriginalFrame(true);
    //运行奔跑动画
    mainsprite->runAction(CCRepeatForever::create(CCAnimate::create(animation)));
    state = 0;
    addChild(mainsprite);
}
Пример #2
0
std::map<int, cocos2d::CCAnimation*>* ShieldedObject::getShieldAnimations()
{
	if (shieldAnimations == NULL)
	{
		shieldAnimations = new map<int, cocos2d::CCAnimation*>;
		for (int i = 0; i < 1; i++)
		{
			CCAnimation *animation;
			animation = CCAnimation::create();
			animation->retain();
			animation->setDelayPerUnit(0.05f);
			animation->addSpriteFrameWithFileName("res/image/shield7.png");
			animation->addSpriteFrameWithFileName("res/image/shield6.png");
			animation->addSpriteFrameWithFileName("res/image/shield5.png");
			animation->addSpriteFrameWithFileName("res/image/shield4.png");
			animation->addSpriteFrameWithFileName("res/image/shield3.png");
			animation->addSpriteFrameWithFileName("res/image/shield2.png");
			animation->addSpriteFrameWithFileName("res/image/shield1.png");
			animation->addSpriteFrameWithFileName("res/image/shield.png");
			animation->addSpriteFrameWithFileName("res/image/shield.png");
			animation->addSpriteFrameWithFileName("res/image/shield.png");
			animation->addSpriteFrameWithFileName("res/image/shield1.png");
			animation->addSpriteFrameWithFileName("res/image/shield2.png");
			animation->addSpriteFrameWithFileName("res/image/shield3.png");
			animation->addSpriteFrameWithFileName("res/image/shield4.png");
			animation->addSpriteFrameWithFileName("res/image/shield5.png");
			animation->addSpriteFrameWithFileName("res/image/shield6.png");
			animation->addSpriteFrameWithFileName("res/image/shield7.png");
			animation->addSpriteFrameWithFileName("res/image/shield0.png");
			(*shieldAnimations)[i] = animation;
		}
	}
	return shieldAnimations;
}
Пример #3
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);
}
Пример #4
0
Файл: coin.cpp Проект: pac94/cpp
void Coin::rotateAction()
{
	CCAnimation* action = CCAnimation::create();
	action->setDelayPerUnit(0.1f);
	action->setRestoreOriginalFrame(true);
	action->addSpriteFrameWithFileName("ring1.png");
	action->addSpriteFrameWithFileName("ring2.png");
	action->addSpriteFrameWithFileName("ring3.png");
	action->addSpriteFrameWithFileName("ring4.png");
	CCAnimate* animate = CCAnimate::create(action);
	CCRepeatForever* repeat = CCRepeatForever::create(animate);
	sprite->runAction(repeat);

}
Пример #5
0
void Motion::SetIdleMotion()
{
    CCAnimation* animation = CCAnimation::create();
    animation->setDelayPerUnit(0.5f/3.0f);
    
    animation->addSpriteFrameWithFileName("breath1.png");
    animation->addSpriteFrameWithFileName("breath2.png");
    animation->addSpriteFrameWithFileName("breath3.png");
    animation->addSpriteFrameWithFileName("breath2.png");
    animation->addSpriteFrameWithFileName("breath1.png");
    
    _idleMotion = CCRepeatForever::create(CCAnimate::create(animation));
    _idleMotion->retain();

}
Пример #6
0
//怪物走动的动画
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;

}
Пример #7
0
//攻击动画
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;

}
Пример #8
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;
}
Пример #9
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;
}
Пример #10
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));
}
Пример #11
0
void TollGateModel::setdie(){
    islife = false;
    mainbody->setVisible(false);
    boom->setVisible(true);
    this->stopAllActions();
    //±¬Õ¨¶¯»­
    CCAnimation* boomAnimation = CCAnimation::create();
    boomAnimation->addSpriteFrameWithFileName("Boom1.png");
    boomAnimation->addSpriteFrameWithFileName("Boom2.png");
    boomAnimation->addSpriteFrameWithFileName("Boom3.png");
    boomAnimation->addSpriteFrameWithFileName("Boom4.png");
    boomAnimation->addSpriteFrameWithFileName("Boom5.png");
    boomAnimation->setDelayPerUnit(0.1f);
    boomAnimation->setRestoreOriginalFrame(true);
    //boom->runAction(CCSequence::create(CCAnimate::create(boomAnimation),CCCallFuncN::create(this, callfuncN_selector(TollGateModel::restart)),NULL));
}
Пример #12
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());
}
Пример #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 GameObjHero::onEnter()
{
	CCNode::onEnter();
	this->setContentSize(CCSizeMake(85,90));

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

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

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

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

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

	offset = ccp(0,0);

	isControl = false;

	schedule(schedule_selector(GameObjHero::releaseBullet),0.3f);
}
Пример #15
0
KDvoid Level1Scene::ScoreAnimation ( CCPoint tPos, const KDchar* szImgName, const KDchar* szImgName2 )
{
	m_pExplosion = CCSprite::create ( szImgName );
	m_pExplosion->setPosition ( tPos );
	this->addChild ( m_pExplosion,0,22 );
	
	CCAnimation*	pAnim = CCAnimation::create ( );		
	pAnim->addSpriteFrameWithFileName ( szImgName );
	pAnim->addSpriteFrameWithFileName ( szImgName2 );

	m_pExplosion->runAction
	(
		CCSequence::create
		(
			CCAnimate	::create ( pAnim ),
			CCCallFuncN	::create ( this, callfuncN_selector ( Level1Scene::spMoveFinished ) ), 
			KD_NULL
		) 
	);
}
Пример #16
0
void Player::fastAction()
{
	inAction = 0;
	CCAnimation* toto = CCAnimation::create();
	toto->setDelayPerUnit(0.04f);
	toto->setRestoreOriginalFrame(true);
	toto->addSpriteFrameWithFileName("speed9.png");
	toto->addSpriteFrameWithFileName("speed10.png");
	toto->addSpriteFrameWithFileName("speed11.png");
	toto->addSpriteFrameWithFileName("speed12.png");
	toto->addSpriteFrameWithFileName("speed13.png");
	toto->addSpriteFrameWithFileName("speed14.png");
	toto->addSpriteFrameWithFileName("speed15.png");
	toto->addSpriteFrameWithFileName("speed16.png");
	sprite->stopAllActions();
	CCAnimate* animate = CCAnimate::create(toto);
	CCRepeatForever* repeat = CCRepeatForever::create(animate);
	CCMoveTo* goMiddle = CCMoveTo::create(1,ccp(size.width/2, size.height/4 + 10));
	sprite->runAction(goMiddle);
	sprite->runAction(repeat);
}
Пример #17
0
void GameObjHero::setState(short var)
{
    if (state == var)
        return ;
    state = var;
    
    switch (state) {
        case 1:
            //跳跃
            this->stopAllActions();
            mainsprite->stopAllActions();
            mainsprite->setTexture(jump);
            this->runAction(CCSequence::create(CCJumpBy::create(2.5,ccp(0,0),100,1),CCCallFuncN::create(this, callfuncN_selector(GameObjHero::jumpend)),NULL));
            break;
        case 2://受伤
            this->stopAllActions();
            mainsprite->stopAllActions();
            mainsprite->setTexture(hurt);
            this->runAction(CCSequence::create(CCBlink::create(3, 10),CCCallFuncN::create(this, callfuncN_selector(GameObjHero::hurtend)),NULL));
            ((GameMain *)this->getParent())->setover();
            break;
        case 0://奔跑动画
            this->stopAllActions();
            mainsprite->stopAllActions();
            CCAnimation * animation = CCAnimation::create();
            animation->addSpriteFrameWithFileName("s_1.png");
            animation->addSpriteFrameWithFileName("s_2.png");
            animation->addSpriteFrameWithFileName("s_3.png");
            animation->addSpriteFrameWithFileName("s_4.png");
            animation->addSpriteFrameWithFileName("s_5.png");
            animation->addSpriteFrameWithFileName("s_6.png");
            animation->setDelayPerUnit(0.1f);
            animation->setRestoreOriginalFrame(true);
            mainsprite->runAction(CCRepeatForever::create(CCAnimate::create(animation)));
            break;
    }
}
Пример #18
0
void Motion::SetRunMotion()
{
    CCAnimation* animation = CCAnimation::create();
    animation->setDelayPerUnit(0.5f/4.0f);  //값이 클을수록 느림
    
    char tmp[100];
    for(int i=1; i<14; i++)
    {
        sprintf(tmp,"charactor_run%d.png",i);
        animation->addSpriteFrameWithFileName(tmp);
    }
    _runMotion = CCRepeatForever::create(CCAnimate::create(animation));
    _runMotion->retain();

}
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;
    
    
}
Пример #20
0
////////////////////////////////////////////////////////////////////////////////
/// \brief      메인 메뉴 추가 - 습관동화
/// \param parentLayer 메뉴가 추가될 부모 CCLayer
/// \param tag layer 태그
////////////////////////////////////////////////////////////////////////////////
void Menu::setMenu_FAIRYTALE(CCLayer* parentLayer, int tag)
{
	CCSize size = CCDirector::sharedDirector()->getWinSize();

	// Modified by magemaster.2013.09.30
	// 초기 실행 시, 메뉴 케릭터 버튼 크기가 애니메이션 이미지와 다른 문제 수정 (애니메이션 첫번째 파일을 초기 이미지로 변경)
	Menu* pMenuBtn;
	if (tag == MENUITEM_MAIN_TAG) {
		pMenuBtn = Menu::MenuWithTexture(CCTextureCache::sharedTextureCache()->addImage("menu/character/main_01.png"));
	}
	else {
		// Main화면용 이미지가 너무 작아서 다른걸로 사용하도록 수정. 2014.1.20
		pMenuBtn = Menu::MenuWithTexture(CCTextureCache::sharedTextureCache()->addImage("menu/character_img_ios.png"));
	}

	pMenuBtn->setPosition(ccp(size.width/2 - 90, 230 ) );
	m_nMenuBtnPos = 230;//pMenuBtn->getContentSize().height / 2;
	parentLayer->setTag(tag);
	parentLayer->addChild(pMenuBtn, 1);
	pMenuBtn->isActiveTouchMenu = true;
	pMenuBtn->addMenuItem();

	if (tag == MENUITEM_MAIN_TAG) {

		CCAnimation *animation = CCAnimation::create();
		animation->setDelayPerUnit(0.5f);

		char str[150] = {0};
		int nImgArr[5] = {1,2,3,4,5};

		for (int i=0; i < 5; i++) {
			sprintf(str,"menu/character/main_%02d.png", nImgArr[i]);
			animation->addSpriteFrameWithFileName(str);
		}

		CCAnimate *animate = CCAnimate::create(animation);
		CCAction *rep1 = CCRepeatForever::create(animate);
		pMenuBtn->runAction(rep1);
		pMenuBtn->setScale(0.5f);
	}
	else
	{
		pMenuBtn->setPosition(ccp(size.width/2 - 90, 300));
		m_nMenuBtnPos = 30;
		pMenuBtn->setScale(0.3f);
	}
	g_pMenuBtn = pMenuBtn;
}
void GameTakeRewardLayer::picRunAction() {
    for (int i = 0; i < myImgList.size(); i ++) {
        myImgList[i] -> stopAllActions();
    }
    
    CCAnimation* pAni = CCAnimation::create();
    CCString str;
    for (int i = 1; i <=2; i ++)
    {
        str.initWithFormat("./CocoStudioResources/takeReward/images/face_%d_%d.png",selectorPic, i);
        pAni->addSpriteFrameWithFileName(str.getCString());
    }
    pAni -> setDelayPerUnit(0.12f);
    pAni -> setLoops(1);
    myImgList[selectorPic -1] -> runAction(CCRepeatForever::create(CCAnimate::create(pAni)));
}
Пример #22
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));
}
Пример #23
0
void MainCharacter::PlayHeroTestAnimation()
{
    CCAnimation* pAnim = CCAnimation::create();
    char str[20];

    for (UINT i = 0; i < 6; ++i)
    {
        sprintf(str,"Hero01_%d.png",i);
        pAnim->addSpriteFrameWithFileName(str);
    }

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

    m_pMainSprite->runAction(CCRepeatForever::create(CCAnimate::create(pAnim)));


    //  Code using plist.

    // 	CCSpriteFrameCache* cache =CCSpriteFrameCache::sharedSpriteFrameCache();
    // 	cache->addSpriteFramesWithFile("attack.plist");
    // 	CCSprite *plistSprite=CCSprite::createWithSpriteFrameName("A1_0.png");
    // 	plistSprite->setPosition(ccp(CCDirector::sharedDirector()->getWinSize().width-plistSprite->getContentSize().width,CCDirector::sharedDirector()->getWinSize().height/2));
    // 	CCSpriteBatchNode* spritebatch =CCSpriteBatchNode::create("attack.png");
    // 	spritebatch->addChild(plistSprite);
    // 	addChild(spritebatch);
    // 
    // 	CCArray* plistArray=CCArray::createWithCapacity(4);
    // 	char name[20];
    // 	for(int i=0;i<4;i++){
    // 		sprintf(name,"A1_%d.png",i);
    // 		CCSpriteFrame* frame =cache->spriteFrameByName(name);
    // 		plistArray->addObject(frame);
    // 	}
    // 
    // 	CCAnimation *plitAnimation=CCAnimation::createWithSpriteFrames(plistArray,0.2f);
    // 	CCAnimate *plitAnimate=CCAnimate::create(plitAnimation);
    // 	CCActionInterval* plitSeq=(CCActionInterval*)(CCSequence::create(plitAnimate,
    // 		CCFlipX::create(true),
    // 		plitAnimate->copy()->autorelease(),
    // 		CCFlipX::create(false),
    // 		NULL
    // 		));
    // 
    // 	plistSprite->runAction(CCRepeatForever::create(plitSeq));
}
Пример #24
0
void TollGateModel::onEnter()
{
    CCNode::onEnter();
    this->setContentSize(CCSizeMake(99,111));
    mainbody = CCSprite::create("DrDog1.png");
    //³õʼ»¯¶¯»­
    CCAnimation* animation = CCAnimation::create();
    animation->addSpriteFrameWithFileName("DrDog1.png");
    animation->addSpriteFrameWithFileName("DrDog2.png");
    animation->setDelayPerUnit(0.1f);
    animation->setRestoreOriginalFrame(true);
    mainbody->runAction(CCRepeatForever::create(CCAnimate::create(animation)));
    addChild(mainbody);
    boom = CCSprite::create("Boom1.png");
    addChild(boom);
    boom->setVisible(false);
    islife = true;
}
Пример #25
0
//受伤动画
void Monster::HurtAnimation(const char *name_each,const unsigned int num,bool run_directon)
{
	if(IsHurt||Isdead)
		return;
	//受伤优先
	if(IsRunning||IsAttack)
	{
	  m_MonsterSprite->stopAllActions();//当前精灵停止所有动画
	   //恢复精灵原来的初始化贴图 
	  this->removeChild(m_MonsterSprite,TRUE);//把原来的精灵删除掉
	  m_MonsterSprite=CCSprite::create(Monster_name);//恢复精灵原来的贴图样子
	  m_MonsterSprite->setFlipX(MonsterDirecton);
	  this->addChild(m_MonsterSprite);
	  IsRunning=false;
	  IsAttack=false;
	}
	

	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(2.8f/14.0f);  
	animation->setRestoreOriginalFrame(true);  
	animation->setLoops(1); //动画循环1次  
	//将动画包装成一个动作
	CCAnimate* act=CCAnimate::create(animation);
	//创建回调动作,受伤动画结束调用HurtEnd()
	CCCallFunc* callFunc=CCCallFunc::create(this,callfunc_selector(Monster::HurtEnd));
	//创建连续动作
	CCActionInterval* hurtackact=CCSequence::create(act,callFunc,NULL);
	
	m_MonsterSprite->runAction(hurtackact);  
	IsHurt=true;


}
Пример #26
0
//死亡动画
void Monster::DeadAnimation(const char *name_each,const unsigned int num,bool run_directon)
{
	Isdead=true;
	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(2.8f/14.0f);  
	animation->setRestoreOriginalFrame(true);  
	animation->setLoops(1); //动画循环1次  
	//将动画包装成一个动作
	CCAnimate* act=CCAnimate::create(animation);
	//创建回调动作,死亡结束后调用deadact()
	CCCallFunc* callFunc=CCCallFunc::create(this,callfunc_selector(Monster::DeadEnd));
	//创建连续动作
	CCActionInterval* deadact=CCSequence::create(act,callFunc,NULL);
	m_MonsterSprite->runAction(deadact);  

}
Пример #27
0
void weatherController::flashAction(float dt){


	CCAnimation *flashing = CCAnimation::create();
	for (int i = 1; i < 5; i++){
		char FileName[128] = { 0 };
		sprintf(FileName, "GamePlayingScene/weather/flash_%d.png", i);
		flashing->addSpriteFrameWithFileName(FileName);
	}

	flashing->setDelayPerUnit(0.3f / 3.0f);
	CCAnimate *action = CCAnimate::create(flashing);
	flash->runAction(action);

	auto p1 = archer::getInstance()->getPositionX();
	auto p2 = cloud->getPositionX();

	//еп╤охк╨миа╣Г╣дн╩жцё╛еп╤ойг╥Яйэик
	if (abs(p1 - p2) < 100){
		archer::getInstance()->attacked(20);
	}
}
Пример #28
0
CCArray* AnimationComponent::eightDirectionActionListWithDir(const char* dir ,int frameCount ,CCSize frameSize ,float delay,const char* pathFormat)
{
	CCArray *actions=new CCArray();
	actions->initWithCapacity(8);
	
	//move action
	char str[255] = {0};
	for (int i=0; i<8; i++) {
		CCArray* animFrames=new CCArray();
		animFrames->initWithCapacity(frameCount);
		CCAnimation* animation = CCAnimation::create();
		for (int j=0; j<frameCount; j++) {
			sprintf(str,pathFormat,dir,i,j);//"%s/%02d%03d.png"
			animation->addSpriteFrameWithFileName(str);
		}
		animation->setDelayPerUnit(delay);
		animation->setRestoreOriginalFrame(true);
		//animation.delay=delay;
		CCAnimate *animate= CCAnimate::create(animation);
		actions->addObject(CCRepeatForever::create((CCActionInterval*)CCSequence::create(animate,NULL)));
		animFrames->release();
	}
	return actions;
}
void GameNewLinker::initBgView(void) {
    CCSize vis = CCDirector::sharedDirector() -> getVisibleSize();
    //设置背景
    CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("./Link/Link0.plist");
    CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("./Link/linkerPic.plist");
    
    auto *picTop = CCSprite::createWithSpriteFrameName("top.png");
    picTop -> setAnchorPoint(ccp(0, 1));
    picTop -> setPosition(ccp(0, vis.height));

    auto *picDown = CCSprite::createWithSpriteFrameName("bottom.png");
    picDown -> setAnchorPoint(ccp(0, 0));
    picDown -> setPosition(ccp(0, 0));
    
    clickRoundTabel = CCSprite::create("./Link/clickCircle.png");
    clickRoundTabel -> setVisible(false);
    addChild(clickRoundTabel, 1000);
    
    addChild(picTop);
    addChild(picDown);
    
    CCAnimation* pAni = CCAnimation::create();
    CCString str;
    for (int i = 1; i <=13; ++i)
    {
        str.initWithFormat("role/pig_grandpa/%d.png",i);
        pAni->addSpriteFrameWithFileName(str.getCString());
    }
    
    pAni->setDelayPerUnit(0.12f);
    pAni->setLoops(1);
    CCSprite* p = CCSprite::create("role/pig_grandpa/1.png");
    p->setPosition(ccp(vis.width/2 ,vis.height - p->getContentSize().height/2 - 93 + 68));
    p->runAction(CCRepeatForever::create(CCAnimate::create(pAni)));
    this->addChild(p, 0);
}
Пример #30
0
bool JS_Result::init(int nGameLevel, int nBGIndex, int nPlayTime)
{
    bool bRet = false;
	m_nGameLevel = nGameLevel;
	m_nPlayTime	 = nPlayTime;
	m_nBGIndex = nBGIndex;
	
	if (EASY == m_nGameLevel) {
		
	}
	else {
	
	}

    do 
    {
		this->setTouchEnabled(true);

		s = CCDirector::sharedDirector()->getWinSize();

	//	CC_BREAK_IF(! CCLayerColor::initWithColor(ccc4(255,255,255,255)));
		CC_BREAK_IF(! CCLayerColor::initWithColor(ccc4(0,0,0,100)));

		// 상단 타이틀 영역
		CCSprite* pTitleBG = CCSprite::create("common/game/game_result_top_bg.png");
		pTitleBG->setPosition(ccp(MARGIN_BG_X, 0));
		pTitleBG->setAnchorPoint(ccp(0, 0));
//		addChild(pTitleBG);


		char szTitle[260];

		// Title 그리기
		char* szLang = LanguageUtil::getLanguageCode();
		sprintf(szTitle, "common/game/jigsaw/result_title_%s.png", szLang);
		CCSprite* pTitle = CCSprite::create(szTitle);
		pTitle->setPosition(ccp(s.width/2, 0));
		this->addChild(pTitle, 3);

		// 배경 이미지 그리기
		CCSprite* pBG = CCSprite::create("common/game/result_game_bg.png");
		pBG->setAnchorPoint(ccp(0, 0));
		pBG->setPosition(ccp(MARGIN_BG_X, 0));
		this->addChild(pBG, 2);

		CCMoveTo* pMoveTo = NULL;
		CCFiniteTimeAction *actionDone = NULL;
		CCFiniteTimeAction *seq = NULL;
/*
		pMoveTo = CCMoveTo::create(0.3f, ccp(190, s.height-180));
		actionDone = CCCallFuncN::create( pTitleBG, NULL);
		seq = CCSequence::create(pMoveTo, actionDone, NULL);
		pTitleBG->runAction(seq);
*/
		pMoveTo = CCMoveTo::create(0.3f, ccp(s.width/2, s.height - pTitleBG->getContentSize().height/2 - 142));
		actionDone = CCCallFuncN::create( pTitle, NULL);
		seq = CCSequence::create(pMoveTo, actionDone, NULL);
		pTitle->runAction(seq);

		pMoveTo = CCMoveTo::create(0.3f, ccp(MARGIN_BG_X, s.height - 652));
		actionDone = CCCallFuncN::create( pBG, NULL);
		seq = CCSequence::create(pMoveTo, actionDone, NULL);
		pBG->runAction(seq);

		// 뒤로가기/다시하기 버튼 표시
		CreateMenu();
	
		// 0.5초 후에 랭킹 정보 읽어와 표시
		scheduleOnce(schedule_selector(JS_Result::displayRanking), 0.5f);
		// 랭킹 정보 읽어와 표시
	//	displayRanking();

		char szFilePath[256];
		// Game 순위 등록 시 표시할 Sprite
		m_pGamewin = CCSprite::create("common/game/character/game_win_01.png");
		m_pGamewin->setPosition(ccp(s.width/2, s.height/2));
		m_pGamewin->setOpacity(0);

		CCAnimation *animation = CCAnimation::create();
		animation->setDelayPerUnit(0.5f);
	
		for (int i=1; i <= 4; i++) {
			sprintf(szFilePath,"common/game/character/game_win_%02d.png",i);
			animation->addSpriteFrameWithFileName(szFilePath);
		}

		CCAnimate *animate = CCAnimate::create(animation);
		CCAction *rep = CCRepeat::create(animate, 2);
	//	m_pGamewin->runAction(rep);

		this->addChild(m_pGamewin, 501);

		// Game 순위 미 등록 시 표시할 Sprite
		m_pGameLose = CCSprite::create("common/game/character/game_lose_01.png");
		m_pGameLose->setPosition(ccp(s.width/2, s.height/2));
		m_pGameLose->setOpacity(0);
	
		CCAnimation *animation2 = CCAnimation::create();
		animation2->setDelayPerUnit(0.5f);

		for (int i=1; i <= 2; i++) {
			sprintf(szFilePath,"common/game/character/game_lose_%02d.png",i);
			animation2->addSpriteFrameWithFileName(szFilePath);
		}

		CCAnimate *animate2 = CCAnimate::create(animation2);
		CCAction *rep2 = CCRepeat::create(animate2, 4);
	//	m_pGameLose->runAction(rep2);

		this->addChild(m_pGameLose, 502);

		// 미등록 순위(순위 밖의 기록일 경우)
		if ( -1 == m_nRank )
		{
			m_pGameLose->setOpacity(255);
			m_pGameLose->runAction(rep2);
		}
		else
		{
			m_pGamewin->setOpacity(255);
			m_pGamewin->runAction(rep);
		}
	
		bRet = true;
    } while (0);

	// 4.5초 후 캐릭터 삭제
	scheduleOnce(schedule_selector(JS_Result::RemoveCharacter), 4.5f);

    return bRet;
}