Exemplo n.º 1
0
void CHeroEvolveEffectLayer::initEffect()
{
	//加载资源-两个动画资源
	if(m_pEffectBase!=nullptr)
	{
		m_pEffectBase->removeFromParentAndCleanup(true);
	}
	m_pEffectBase = CCArmature::create("evol2");
	m_pEffectBase->setPosition(ccp(DESIGN_WIDTH/2, VIRTUAL_FIXED_HEIGHT/2));
	m_pUI->addChild(m_pEffectBase, -2);
	m_pEffectBase->getAnimation()->setFrameEventCallFunc(this, frameEvent_selector(CHeroEvolveEffectLayer::frameEventCallBack));
	m_pEffectBase->getAnimation()->setMovementEventCallFunc(this, movementEvent_selector(CHeroEvolveEffectLayer::movementCallBack));


	if(m_pEffectForChange!=nullptr)
	{
		m_pEffectForChange->removeFromParentAndCleanup(true);
	}
	m_pEffectForChange = CCArmature::create("evol");
	m_pEffectForChange->setPosition(ccp(DESIGN_WIDTH/2, VIRTUAL_FIXED_HEIGHT/2));
	m_pUI->addChild(m_pEffectForChange, -2);
	m_pEffectForChange->getAnimation()->setFrameEventCallFunc(this, frameEvent_selector(CHeroEvolveEffectLayer::frameEventCallBack));
	m_pEffectForChange->getAnimation()->setMovementEventCallFunc(this, movementEvent_selector(CHeroEvolveEffectLayer::movementCallBack));

}
void HelloWorld::update(float delta)
{
	if(m_bStart)
	{
		CCArmature *pHero = (CCArmature*)(m_pGameScene->getChildByTag(10005)->getComponent("CCArmature")->getNode());
		pHero->getParent()->setPositionX(pHero->getParent()->getPositionX() + m_fSpeed);
		CCArmature *pEnemy = (CCArmature*)(m_pGameScene->getChildByTag(10006)->getComponent("CCArmature")->getNode());

		if(ccpDistance(ccp(pHero->getParent()->getPositionX(), 0), ccp(pEnemy->getParent()->getPositionX(), 0)) < m_fAttackDis)
		{	
			pHero->getAnimation()->play("attack");
			pHero->getAnimation()->setMovementEventCallFunc(this,
                                                        movementEvent_selector(HelloWorld::animationEvent));
			m_bStart = false;
		}
	}

	if(m_bDead)
	{
		CCComRender *pUIRender = static_cast<CCComRender*>(m_pGameScene->getChildByTag(10007)->getComponent("GUIComponent"));
		UILayer *pUILayer = static_cast<UILayer*>(pUIRender->getNode());
		UILoadingBar *pHPLoadingBar = static_cast<UILoadingBar*>(pUILayer->getWidgetByName("hp02_LoadingBar"));
		UILoadingBar *pMPLoadingBar = static_cast<UILoadingBar*>(pUILayer->getWidgetByName("mp02_LoadingBar"));

		pHPLoadingBar->setPercent(m_fPercentage);
		pMPLoadingBar->setPercent(m_fPercentage);

		m_fPercentage -= 2.0f;
        if (m_fPercentage < 0.0f) {
            unscheduleUpdate();
        }
	}
	
}
CCArmature* AnimLoader::createAnimationOneTime(const char *resName, const char *animName)
{
	CCArmature *armature = CCArmature::create(resName);
	armature->getAnimation()->play(animName, 0, 0, 1, 0);
	armature->getAnimation()->setMovementEventCallFunc(armature, movementEvent_selector(AnimLoader::removeAnim));
	return armature;
}
Exemplo n.º 4
0
inline
void CNpc::animation_reBack()
{
    CGameElement::setCurrentAnimation(ARMATURE_GUARD_DIE_REVIVE);
    getArmature()->getAnimation()->setMovementEventCallFunc(this, movementEvent_selector(CNpc::movementCallback));
    getArmature()->getAnimation()->play(PLAYLAB_GUARD_REVIVE);
}
Exemplo n.º 5
0
void Battle::enemydisappear(void *context, const s32 size) {
    Enemy * enemy = (Enemy *)context;
    ENEMY_GROUP::iterator iend = m_enemyGroup.end();
    ENEMY_GROUP::iterator itor = ::find(m_enemyGroup.begin(), iend, enemy);
    if (itor == iend) {
        CCASSERT(false, "... where r u from");
    } else {
        m_enemyGroup.erase(itor);
    }
    
    s_enemy_count--;
    CCASSERT(s_enemy_count>=0, "check ur enemy");
    if (0 == s_enemy_count) {
        s_itor++;
        if (s_itor != m_pConfig->events.end()) {
            CTimer * timer = CTimer::create(&(*s_itor), BUND_ID_BATTLE_EVENT, 0, 0, s_itor->delay);
            addChild(timer);
        } else {
            if (m_pConfig->boss != "") {
                mask();
                g_pEventEngine->BundlerCall(BUND_ID_PLANE_HOLD_FIRE, this, sizeof(this));
                ArmatureDataManager::getInstance()->addArmatureFileInfo("Animation/UI/bosswarning.ExportJson");
                m_pBossIn = Armature::create("bosswarning");
                m_pBossIn->setAnchorPoint(Vec2(.5f, .5f));
                this->addChild(m_pBossIn, GRADE_UI);
                m_pBossIn->setPosition(g_pGameConfig->screenCenterPoint);
                m_pBossIn->getAnimation()->playWithIndex(0);
                m_pBossIn->setScale(g_pGameConfig->scaleEleMin * 1.5f);
                m_pBossIn->getAnimation()->setMovementEventCallFunc(this, movementEvent_selector(Battle::playActionOver));
            } else {
                requestpve();
            }
        }
    }
}
Exemplo n.º 6
0
void PlayScene::RunAction(CCPoint pos, const char* name) {
  CCArmatureDataManager::sharedArmatureDataManager()->addArmatureFileInfo("Action/Action.ExportJson");
  CCArmature *armature = CCArmature::create("Action");
  armature->getAnimation()->play(name);
  armature->setPosition(pos);
  this->addChild(armature, 2, 102);
  armature->getAnimation()->setMovementEventCallFunc(this,movementEvent_selector(PlayScene::ArmatureCallBack));
}
Exemplo n.º 7
0
//÷È»ó¼¼ÄÜ
void CNpc::animation_confuse()
{
    CAnimationAxis* aa = findCreateByIndex(INDEX_NPCINDEX_CONFUES);

    aa->setCurrentAnimation(ARMATURE_COOKING_MAGIC_EFFIE);
    aa->getArmature()->getAnimation()->setMovementEventCallFunc(this, movementEvent_selector(CNpc::movementCallback));
    aa->getArmature()->getAnimation()->play(PLAYLAB_COOLKING_MAGIC_EFFIE);
}
Exemplo n.º 8
0
void CDragon::onEnter()
{
    CBoss::onEnter();

    //---------------------------------------------

    //风魔龙闪电云技能
    T_SkillDragonLighing* skilllight    = new T_SkillDragonLighing();
    skilllight->m_fMaxTime              = 10; //   
    skilllight->init();

    //风魔龙 龙卷风技能
    T_SkillDrogTornado* pSkillTornado   = new T_SkillDrogTornado();
    pSkillTornado->m_fMaxTime           = 120;
    pSkillTornado->m_fMAXWhiteTime      = 3;
    pSkillTornado->m_fMAXBlackTime      = 4;
    pSkillTornado->init();

    //风魔龙 龙卷风技能
    T_RandSkill allRandSkill[] = 
    {
        //{ 3, 0, Skill::SKILL_T_LIGHTING, RandSkill_State::RANDSKILL_STATE_CD, (T_SkillData*)skilllight },
        { 3, 0, Skill::SKILL_T_TORNADO, RandSkill_State::RANDSKILL_STATE_CD, (T_SkillData*)pSkillTornado }
    
    };
    
    int size = sizeof(allRandSkill) / sizeof(allRandSkill[0]);
    for (int i = 0; i < size;i++)
    {
        T_RandSkill* randskill      = new T_RandSkill();

        randskill->m_iMaxCD         = allRandSkill[i].m_iMaxCD;
        randskill->m_iSkillCd       = allRandSkill[i].m_iSkillCd;
        randskill->m_iSkillId       = allRandSkill[i].m_iSkillId;
        randskill->m_iSkillState    = allRandSkill[i].m_iSkillState;
        randskill->m_pSkill         = allRandSkill[i].m_pSkill;

        randskill->init();

        m_oAllRandSkill.push_back(randskill);
    }

    createSkillTimer();
    
    //======================================

    clearCurrentAnimation();    
    setCurrentAnimation(ARMATURE_DRAGON);
    getArmature()->getAnimation()->setMovementEventCallFunc(this, movementEvent_selector(CDragon::movementCallback));
    getArmature()->getAnimation()->playByIndex(0);

    //-------------------------------------

    int t_direct    = CPath::DIRECT[CMath::getRandom(0, 3)][0];
    m_iDirect       = t_direct + CMath::getRandom(-30, 30);
    changeDirect(t_direct);
}
Exemplo n.º 9
0
Player::Player(CCNode* playerNode)
:CCObject()
{
    this->playerNode = playerNode;
    CCArmature* animationNode = (CCArmature*)playerNode->getComponent("CCArmature")->getNode();
    this->animation = animationNode->getAnimation();
    this->animation->setMovementEventCallFunc(this, movementEvent_selector(Player::onAnimationEvent));
    currentState = IDLE;
    newState = IDLE;
    lockState = false;
}
Exemplo n.º 10
0
void Boss::disappear() {
    g_pEventEngine->BundlerCall(BUND_ID_BOSS_DISAPPEAR, this, sizeof(this));
    unscheduleAllSelectors();
    stopAllActions();
    string ejson = string("Animation/Effect/") + m_pConfig->boom + ".ExportJson";
    ArmatureDataManager::getInstance()->addArmatureFileInfo(ejson);
    m_pBoom = Armature::create(m_pConfig->boom);
    m_pBoom->getAnimation()->play("boom");
    this->addChild(m_pBoom);
    m_pBoom->getAnimation()->setMovementEventCallFunc(this, movementEvent_selector(Boss::playActionOver));
}
Exemplo n.º 11
0
void GameArmature::startWithTarget(CCNode *pTarget)
{
	CCAction::startWithTarget(pTarget);
	IArmature::startWithTarget(pTarget);
	Obj* obj=dynamic_cast<Obj*>(pTarget);
	if(obj&&!m_bLoop)
	{
		obj->getAnimation()->setMovementEventCallFunc(this, movementEvent_selector(GameArmature::animationEvent));
	}
	
}
Exemplo n.º 12
0
void Battle::onEnter() {
    PublicUI::onEnter();
    CCASSERT(s_mission_name != ""
             && NULL != (m_pConfig = g_pGameConfig->getMissionConfig(s_mission_name)),
             "set mission first");
    
    schedule(schedule_selector(Battle::collidtion), 1/60.0f);
    
    m_pBoss = NULL;
    
    mask();
    ArmatureDataManager::getInstance()->addArmatureFileInfo("Animation/UI/readygo.ExportJson");
    m_pReadygo = Armature::create("readygo");
    m_pReadygo->setAnchorPoint(Vec2(.5f, .5f));
    this->addChild(m_pReadygo, GRADE_UI);
    m_pReadygo->setPosition(g_pGameConfig->screenCenterPoint);
    m_pReadygo->getAnimation()->play("readygo");
    m_pReadygo->setScale(g_pGameConfig->scaleEleMin * 1.5f);
    m_pReadygo->getAnimation()->setMovementEventCallFunc(this, movementEvent_selector(Battle::playActionOver));
    
    s_enemy_count = 0;
    s_itor = m_pConfig->events.begin();
    if (s_itor != m_pConfig->events.end()) {
        CTimer * timer = CTimer::create(&(*s_itor), BUND_ID_BATTLE_EVENT, 0, 0, s_itor->delay);
        addChild(timer);
    }
    
    BIND(BUND_ID_BULLET_FIRED, this, Battle::bulletFired);
    BIND(BUND_ID_BULLET_DISAPPEARED, this, Battle::bulletDisappear);
    BIND(BUND_ID_BATTLE_EVENT, this, Battle::event_exec);
    BIND(BUND_ID_ENEMY_EVENT, this, Battle::enemy_event);
    BIND(BUND_ID_ENEMY_DISAPPEAR, this, Battle::enemydisappear);
    BIND(BUND_ID_PLANE_DISAPPEAR, this, Battle::planedisappear);
    BIND(BUND_ID_PLANE_INJURED, this, Battle::planeinjured);
    BIND(BUND_ID_GLOBAL_TOUCH_BEGAN, this, Battle::globalTouchBegan);
    BIND(BUND_ID_BOSS_DISAPPEAR, this, Battle::bossdisappear);
    
    SEquip equip;
    g_pEquipManager->getGrooveEquip(EQUIP_TYPE_PLANE, equip);
    m_pPlane = Plane::create(equip);
    m_pPlane->setScale(g_pGameConfig->scaleEleMin * .75f);
    g_pEquipManager->getGrooveEquip(EQUIP_TYPE_WEAPON, equip);
    m_pPlane->addWeapon(equip);
    g_pEquipManager->getGrooveEquip(EQUIP_TYPE_WINGMAN, equip);
    m_pPlane->addWingman(equip);
    
    g_pEquipManager->getGrooveEquip(EQUIP_TYPE_ARMOR, equip);
    m_pPlane->addArmor(equip);
    
    m_pPlane->setPosition(Vec2(g_pGameConfig->screenCenterPoint.x, 0));
    addChild(m_pPlane, GRADE_PLAYER);
    ActionInterval * action = EaseExponentialOut::create(MoveBy::create(2, Vec2(0, 500 * g_pGameConfig->scaleEleY)));
    m_pPlane->runAction(action);
}
Exemplo n.º 13
0
//-----------------------------------------------------------------------------------------------------------------------------
// 设置形象
void PersonView::setAvatar(CCArmature* avatar)
{
    if (mAvatar != NULL)
    {
        removeChild(mAvatar, true);
        mAvatar = 0;
    }
    mAvatar = avatar;
    mAvatar->getAnimation()->setMovementEventCallFunc(this, movementEvent_selector(PersonView::onAnimationComplete));
    addChild(mAvatar, 0);
    mAvatar->getAnimation()->play(STATE_STAND);
}
Exemplo n.º 14
0
void Battle::pve_vector(float) {
    mask();
    ArmatureDataManager::getInstance()->addArmatureFileInfo("Animation/UI/missionVictory.ExportJson");
    m_pMissionVictory = Armature::create("missionVictory");
    m_pMissionVictory->setScale(g_pGameConfig->scaleEleMin);
    m_pMissionVictory->setAnchorPoint(Vec2(.5f, .5f));
    addChild(m_pMissionVictory, GRADE_MAX);
    m_pMissionVictory->setPosition(g_pGameConfig->screenCenterPoint);
    m_pMissionVictory->getAnimation()->playWithIndex(0);
    m_pMissionVictory->setScale(g_pGameConfig->scaleEleMin * 1.5f);
    m_pMissionVictory->getAnimation()->setMovementEventCallFunc(this, movementEvent_selector(Battle::playActionOver));
}
Exemplo n.º 15
0
Boss::Boss(const BossConfig * pConfig) {
    m_pConfig = pConfig;
    init(m_pConfig->radius);
    string ejson = string("Animation/Boss/") + m_pConfig->res + ".ExportJson";
    ArmatureDataManager::getInstance()->addArmatureFileInfo(ejson);
    m_pBoss = Armature::create(m_pConfig->res);
    m_pBoss->setAnchorPoint(Vec2(.5f, .5f));
    this->addChild(m_pBoss);
    m_pBoss->getAnimation()->play("fly");
    setContentSize(m_pBoss->getContentSize());
    m_pBoss->getAnimation()->setMovementEventCallFunc(this, movementEvent_selector(Boss::playActionOver));
    m_armor= pConfig->armor;
}
Exemplo n.º 16
0
void Hero::airHurt()
{
	if (faceto)
	{
		velocityX = 2;
	}
	else
	{
		velocityX = -2;
	}
	velocityY = 5;
	m_sprite->getAnimation()->play("FlankHurt");
	this->scheduleOnce(schedule_selector(Hero::doHurt),0.33f);
	m_sprite->getAnimation()->setMovementEventCallFunc(this,movementEvent_selector(Hero::hurtCallBack));
}
Exemplo n.º 17
0
bool EnemyZ::init()
{
	if (!CCArmature::init("EnemyZAnimation"))
	{
		return false;
	}
	this->m_gold=80;
	this->m_goldPercentage=0.5f;
	this->setExperience(20);
	this->setHitPoints(100.0);   //受到的伤害
	this->setDamage(10.0);   
	this->setWalkSpeed(100.0);    //走路速速
	this->setScale(0.4);
	this->scale=-0.4;

	//_spriteBox=new SpriteBox(ccp(-20,-55),CCSizeMake(65,80),ccp(-65,-50),CCSizeMake(65,50));
	SetSpriteBox(ccp(-20,-55),CCSizeMake(65,80),ccp(-65,-50),CCSizeMake(65,50));
	//this->setHitbox(createBoundingBoxWithOrigin(ccp(-20,-55),CCSizeMake(65,80)));
	//this->setAttackBox(createBoundingBoxWithOrigin(ccp(-65,-50),CCSizeMake(65,50)));

	this->getAnimation()->setFrameEventCallFunc(this, frameEvent_selector(EnemyZ::onFrameEvent));
	this->getAnimation()->setMovementEventCallFunc(this, movementEvent_selector(EnemyZ::animationEvent));
	return true;
}
Exemplo n.º 18
0
/// 导入动画数据
CCArmatureDataManager::sharedArmatureDataManager()->addArmatureFileInfo("testAnimation/testAnimation0.png","testAnimation/testAnimation0.plist","testAnimation/testAnimation.ExportJson");
m_pArmature = CCArmature::create("testAnimation");
CCArmatureAnimation *pAnimation = m_pArmature->getAnimation();
pAnimation->play("ColorGreen");
// 	/// 设置动作循环情况
// 	pAnimation->setLoopType(ANIMATION_TO_LOOP_FRONT);
pAnimation->setMovementEventCallFunc(this, movementEvent_selector(HelloWorld::onAnimationEvent));	///< 监听角色动作状态 
pAnimation->setFrameEventCallFunc(this, frameEvent_selector(HelloWorld::onFrameEvent));				///< 设置帧监听事件
m_pArmature->setPosition(ccp(200, 200));

addChild(m_pArmature, 1);

void HelloWorld::onAnimationEvent( cocos2d::extension::CCArmature *pArmature, cocos2d::extension::MovementEventType eventType, const char *animationID )
{
	/// LOOP_COMPLETE 只有在动作是循环播放时,且每循环一次响应一次
	if (eventType == LOOP_COMPLETE)
	{  
		CCLOG("LOOP_COMPLETE");
	}  

	if (eventType == START)
	{
		CCLOG("START");
	}

	/// COMPLETE--只有在动作设置为不循环播放时才在动画结束响应一次
	if (eventType == COMPLETE)
	{
		CCLOG("COMPLETE");
	}
Exemplo n.º 19
0
void Hero::SB_HeadHurt()
{
	m_sprite->getAnimation()->play("SB_HeadHurt");
	this->scheduleOnce(schedule_selector(Hero::doHurt),0.33f);
	m_sprite->getAnimation()->setMovementEventCallFunc(this,movementEvent_selector(Hero::hurtCallBack));
}