コード例 #1
0
Animation* GameUtils::getAnimationByKeyAndFileName(const std::string& aniKey, const std::string& fileName,
                                                   
                                                   
                                                   const int& frameCount, float delay){
    auto animCache = AnimationCache::getInstance();
    auto resultAnimation = animCache->getAnimation(aniKey);
    if( resultAnimation == nullptr){
        auto cache = Director::getInstance()->getTextureCache();
        Vector<SpriteFrame*> animFrames(frameCount);
        char str[50] = {0};
        for(int i = 0; i < frameCount; i++){
            sprintf(str, fileName.c_str(),i);
            auto texture = cache->addImage(str);
            CCASSERT(texture != nullptr, "texture is null!");
            auto size = texture->getContentSize();
            auto rect = Rect(0, 0, size.width, size.height);
            auto frame = SpriteFrame::createWithTexture(texture, rect);
            animFrames.pushBack(frame);
        }
        auto animation = Animation::createWithSpriteFrames(animFrames, delay);
        
        // Add an animation to the Cache
        AnimationCache::getInstance()->addAnimation(animation, aniKey);
        animFrames.clear();
        resultAnimation = animCache->getAnimation(aniKey);
        //log("no cache");
    }
    return resultAnimation;
}
コード例 #2
0
ファイル: HeroKnight.cpp プロジェクト: 37947538/Young3_7
//普通攻击
std::string HeroKnight::commonAttack()
{
    m_vVelocity*=0.1;
    
    Vec2 diff=Vec2::ZERO;
    
    auto m_Armature=getArmature();
    std::string strAnimateName= m_Armature->getAnimation()->getCurrentMovementID();
    
    std::string strPlayName="";
    if (getAnimateState(getActionFileMode()->ActionAttackName1)==BaseActionObject::AnimateState::Runing) {
        float currPercent= m_Armature->getAnimation()->getCurrentPercent();
        if (currPercent < 0.96) return getActionFileMode()->ActionAttackName1;
        strPlayName=getActionFileMode()->ActionAttackName2;
    }else if(getAnimateState(getActionFileMode()->ActionAttackName2)==BaseActionObject::AnimateState::Runing){
        float currPercent= m_Armature->getAnimation()->getCurrentPercent();
        if (currPercent < 0.94) return getActionFileMode()->ActionAttackName2;
        strPlayName=getActionFileMode()->ActionAttackName3;
    }else if(getAnimateState(getActionFileMode()->ActionAttackName3)==BaseActionObject::AnimateState::Runing){
        float currPercent= m_Armature->getAnimation()->getCurrentPercent();
        if (currPercent < 0.65) return getActionFileMode()->ActionAttackName3;
        strPlayName=getActionFileMode()->ActionAttackName4;
    }else if(getAnimateState(getActionFileMode()->ActionAttackName4)==BaseActionObject::AnimateState::Runing){
        float currPercent= m_Armature->getAnimation()->getCurrentPercent();
        if (currPercent < 0.99) return getActionFileMode()->ActionAttackName4;
        strPlayName=getActionFileMode()->ActionAttackName1;
    }else{
        strPlayName=getActionFileMode()->ActionAttackName1;
    }
    //log("strPlayName:%s",strPlayName.c_str());
    playAnimate(strPlayName);
    m_BodyState=GameEnum::BodyState::Attack;
    return strPlayName;
}
コード例 #3
0
ファイル: bbant.cpp プロジェクト: 33d/scummvm
void MinigameBbAnt::buildDrawList2(DrawList &drawList) {
	buildDrawList1(drawList);
	drawList.add(getAnimation(168)->frameIndices[0], 40, 100, 2000);
	drawNumber(drawList, _counter1, 190, 112);
	drawNumber(drawList, _countdown5, 258, 112);
	drawList.add(getAnimation(169)->frameIndices[0], 120, 120, 2000);
	drawNumber(drawList, _counter4, 192, 132);
}
コード例 #4
0
ファイル: Character.cpp プロジェクト: Risist/ggj2016-game
void Character::swordScript()
{

	switch (swordState)
	{
	case Character::release:
		if (isPressed("s2"))
		{
			swordState = Character::under;
		}
		break;
	case Character::under:
		if (isPressed("s2"))
		{
			auto state = getAnimation("atackH").updateInRange(allModels, getAnimation("atackH").getSpeed());
			if (!state)
				swordState = Character::awaiting;

		}
		else
			swordState = Character::returns;
		break;
	case Character::awaiting:
		if (isPressed("s2"))
		{

		}
		else
		{
			swordState = Character::returns;
			onSwing(10);
		}
		break;
	case Character::returns:
		if (!isPressed("s2"))
		{
			auto state = getAnimation("atackH").updateInRange(allModels, -getAnimation("atackH").getSpeed() * 2.5);
			if (!state)
				swordState = Character::release;

		}
		else
			swordState = Character::under;
		break;
	default:
		break;
	}
	/*if (isPressed("s2"))
	{
		getAnimation("atackH").updateReturn(allModels);

		//getResource_f(idAnimAtU).addForce(-getDrag().y);
		//getResource_f(idAnimAtH).addForce(-getDrag().x);
	}*/

	//getAnimation("atackH").updateInRange(allModels, getResourceC_f(idAnimAtH).velocity);
	//getAnimation("atackU").updateInRange(allModels, getResourceC_f(idAnimAtU).velocity);
}
コード例 #5
0
ファイル: DBArmature.cpp プロジェクト: JustDo1989/dragonbones
bool DBArmature::initWithName(const std::string &name,const std::string &textureName)
{
    CC_SAFE_RELEASE_NULL(_eventDataMgr);
    _eventDataMgr = DBEventDataMgr::create();
    CC_SAFE_RETAIN(_eventDataMgr);
    
    DragonBonesData* dragonBonesData = DBCCFactory::getInstance()->getDragonBonesData(name);
    if (!dragonBonesData)
    {
        return false;
    }
    
    float version = atof(dragonBonesData->version.c_str());
    if (version >= 4.5)
    {
        this->_skewEnable = true;
    }
    
    _pArmatureData = dragonBonesData->getArmatureData(name);
    if (!_pArmatureData)
    {
        _pArmatureData = dragonBonesData->getArmatureDataFirst();
        if (!_pArmatureData)
        {
            return false;
        }
    }
    
    _name = name;
    DBAnimation* animation = DBAnimation::create(this);
    this->setAnimation(animation);
    animation->setAnimationDataList(_pArmatureData->animationDataList);
    
    for (size_t i = 0, l = _pArmatureData->boneDataList.size(); i < l; ++i)
    {
        createBone(_pArmatureData->boneDataList.at(i));
    }

    buildIK();
    updateBoneCache();
    createSkin(textureName);
    
    
    this->setCascadeColorEnabled(true);
    this->setCascadeOpacityEnabled(true);
    
    
    // update armature pose
    getAnimation()->play();
    update(0);
    getAnimation()->stop();
    
    dragonBonesData->retain();
    
    return true;
}
コード例 #6
0
ファイル: DAEUtil.cpp プロジェクト: brobits/GamePlay
bool sameAnimation(std::list<domChannelRef>& channels)
{
    std::list<domChannelRef>::iterator it = channels.begin();
    domAnimation* temp = getAnimation(*it);
    ++it;
    for (; it != channels.end(); ++it)
    {
        if (getAnimation(*it) != temp)
            return false;
    }
    return true;
}
コード例 #7
0
ファイル: Player.cpp プロジェクト: Orrexon/SummerGame
void Player::update(float deltatime)
{
	const sf::Vector2f gravity = { 0.f, 9.8f };
	const sf::Vector2f vRight= { 1.f, 1.f };
	const sf::Vector2f vLeft = { -1.f, 1.f };
	handleInput(deltatime, gravity);
	scaleSprite(vLeft, vRight);
	m_velocity.y += deltatime * gravity.y;
	if (!onGround)
	{
		m_eAnimationType = JUMPING;
		
	}
	else if(onGround)
	{
		m_eAnimationType = IDLE;
	}
	if (m_eAnimationType == WALKING)
	{
		m_animatedSprite->play(*getAnimation("walking"));
	}
	else if (m_eAnimationType == JUMPING)
	{
		m_animatedSprite->play(*getAnimation("jump"));
		m_animatedSprite->setLooped(false);
		onGround = false;
	}
	else if (m_eAnimationType == IDLE)
	{
		m_animatedSprite->play(*getAnimation("idle"));
	}
	else if (m_eAnimationType == DUCKING)
	{
		m_animatedSprite->play(*getAnimation("duck")); 
	}
	else if (m_eAnimationType == SHOOTING)
	{
		//something's up with this
		m_animatedSprite->play(*getAnimation("shooting"));
	}
	m_position += m_velocity;
	m_boxCollider->SetPosition(m_position);
	TestBodyRect.setPosition(m_position);
	m_animatedSprite->setPosition(m_position);
	m_animatedSprite->setOrigin(m_animatedSprite->getLocalBounds().width / 2, m_animatedSprite->getLocalBounds().height / 2);
	

	m_eAnimationType = IDLE;
	m_velocity *= 0.9f;
	bRight = false;
	bLeft = false;
}
コード例 #8
0
ファイル: sr-ship.cpp プロジェクト: Matt-LiYue/space-rodeo
void Ship::updateOrientation(){
  if (_shipState != REST) {
    float degrees = 180 / M_PI * atan(_spd.y/_spd.x);
    if (fabs(_spd.x) < FLT_EPSILON) degrees = 0;
    if (_spd.x < 0) degrees += -180;
    getAnimation()->setRotation(degrees);
		setRotation(degrees + 90);
  }
	else {
		getAnimation()->setRotation(_restAngle);
		setRotation(_restAngle + 90);
	}
}
コード例 #9
0
ファイル: bbant.cpp プロジェクト: 33d/scummvm
void MinigameBbAnt::initObjects1() {
	_objects[0].kind = 0;
	_objects[0].x = 160;
	_objects[0].y = 120;
	_objects[0].xIncr = 0;
	_objects[0].yIncr = 0;
	_objects[0].anim = getAnimation(159);
	_objects[0].frameIndex = 0;
	_objects[0].ticks = _objects[0].anim->frameTicks[0];
	_objects[0].priority = 1000;
	_objects[1].kind = 8;
	_objects[1].x = 0x1E0000;
	_objects[1].y = 0x280000;
	_objects[1].xIncr = 0;
	_objects[1].yIncr = 0;
	_objects[1].anim = getAnimation(160);
	_objects[1].frameIndex = 0;
	_objects[1].ticks = _objects[0].anim->frameTicks[0];
	_objects[1].priority = 900;
	_objects[1].smokeCtr = 0;
	_objects[1].hasSmoke = false;
	_objects[1].status = 0;
	_objects[2].kind = 8;
	_objects[2].x = 0x280000;
	_objects[2].y = 0x4B0000;
	_objects[2].xIncr = 0;
	_objects[2].yIncr = 0;
	_objects[2].anim = getAnimation(161);
	_objects[2].frameIndex = 0;
	_objects[2].ticks = _objects[0].anim->frameTicks[0];
	_objects[2].priority = 900;
	_objects[2].smokeCtr = 0;
	_objects[2].hasSmoke = false;
	_objects[2].status = 0;
	for (int i = 3; i < 12; ++i) {
		const ObjInit *objInit = getObjInit(i - 3);
		_objects[i].kind = 6;
		_objects[i].x = objInit->x << 16;
		_objects[i].y = objInit->y << 16;
		_objects[i].xIncr = 0;
		_objects[i].yIncr = 0;
		_objects[i].anim = objInit->anim1;
		_objects[i].frameIndex = 0;
		_objects[i].ticks = _objects[0].anim->frameTicks[0];
		_objects[i].priority = 600;
		_objects[i].status = 9;
		_objects[i].damageCtr = 0;

	}
}
コード例 #10
0
ファイル: Player.cpp プロジェクト: Clever-Boy/mario
void Player::updateAnimation()
{
	if (m_currentAnimation == PlayerAnimationStep::JUMP_RIGHT || m_currentAnimation == PlayerAnimationStep::JUMP_LEFT)
	{
		getAnimation().increaseDelta();
	} 
	else if (movementVector.dx > 0 && m_currentAnimation == PlayerAnimationStep::RUN_RIGHT)
	{
		getAnimation().increaseDelta();
	}
	else if (movementVector.dx < 0 && m_currentAnimation == PlayerAnimationStep::RUN_LEFT)
	{
		getAnimation().increaseDelta();
	}
}
コード例 #11
0
void PerformanceTest::_addArmature()
{
    const auto armature = _factory.buildArmature(_dragonBonesData->getArmatureNames()[1]);
    const auto armatureDisplay = static_cast<dragonBones::CCArmatureDisplayContainer*>(armature->getDisplay());

    armatureDisplay->setScale(0.3f);
    this->addChild(armatureDisplay);

    armature->setCacheFrameRate(24);
    armature->getAnimation().play(armature->getAnimation().getAnimationNames()[0], 0);
    dragonBones::WorldClock::clock.add(armature);

    _armatures.push_back(armature);
    _updateText();
}
コード例 #12
0
ファイル: Npc.cpp プロジェクト: CarlosPerezPuertas/Action-RPG
void Npc::moveUp(int px)
{
	Action GoUp;
	Action AnimReset;

	GoUp.action = get_action<Npc>([this, px](Npc &npc, sf::Time dt)
	{
		if (getAnimationState() != static_cast<int>(Animations::GoUp))
		{
			animation.play();
			changeAnimation(static_cast<int>(Animations::GoUp));
			getAnimation().play();
		}
		return goUpUntil(px);
	});

	AnimReset.action = get_action<Npc>([this](Npc &npc, sf::Time dt)
	{
		animation.reset();
		return false;
	});

	action_queue.push(GoUp);
	action_queue.push(AnimReset);
}
コード例 #13
0
ファイル: FlashSpell.cpp プロジェクト: MORTAL2000/Cendric2
void FlashSpell::load(const SpellData& data, LevelMovableGameObject* mob, const sf::Vector2f& target) {
	setSpriteOffset(sf::Vector2f(-10.f, 0.f));
	m_mob = mob;
	
	Animation* spellAnimation = new Animation(sf::milliseconds(200));
	spellAnimation->setSpriteSheet(g_resourceManager->getTexture(ResourceID::Texture_spell_flash));
	spellAnimation->addFrame(sf::IntRect(0, 0, 120, 120));
	spellAnimation->addFrame(sf::IntRect(120, 0, 120, 120));

	addAnimation(GameObjectState::Idle, spellAnimation);

	// initial values
	setCurrentAnimation(getAnimation(GameObjectState::Idle), false);
	playCurrentAnimation(true);
	
	Spell::load(data, mob, target);
	m_isFlashingRight = mob->isFacingRight();
	
	m_flashingTime = FLASHING_TIME;
	m_flashDuration = FLASH_DURATION;

	sf::Vector2f position(m_mob->getPosition());
	position.x += (m_mob->getBoundingBox()->width / 2.f);
	position.y += m_mob->getBoundingBox()->height - 20;
	position.x = m_isFlashingRight ? position.x - data.range : position.x + data.range;
	loadParticleSystem();
	m_posGenerator->center = position;
}
コード例 #14
0
ファイル: AnimationCom.cpp プロジェクト: ElvisQin/genius-x
void AnimationCom::playAnimation(const std::string& name,cocos2d::Node* parent,std::function<void()> callback,const cocos2d::Point& point)
{
    auto iter=animations.find(name);
    if (iter!=animations.end()) {
        auto cache = cocos2d::AnimationCache::getInstance();
        auto animation = cache->getAnimation(name);
        auto action2 = cocos2d::Animate::create(animation);
        
        auto animationFrame=animation->getFrames().at(0);
        
        cocos2d::Sprite* sprite=cocos2d::Sprite::createWithSpriteFrame(animationFrame->getSpriteFrame());
        sprite->setAnchorPoint(iter->second.anchorPoint);
        
        if (point.equals(cocos2d::Point::ZERO)) {
            sprite->setPosition(iter->second.position);
        }
        else{
            sprite->setPosition(point);
        }
        
        sprite->setScale(iter->second.scale.x, iter->second.scale.y);
        sprite->setLocalZOrder(iter->second.localZOrder);
        parent->addChild(sprite);
        
        //animation->setDelayPerUnit(iter->second.delayPerUnit);
        //animation->setLoops(iter->second.loops);
        
        sprite->runAction(cocos2d::Sequence::create(action2, cocos2d::RemoveSelf::create(), NULL));
    }
}
コード例 #15
0
void AnimationEffect::finished()
{
    AnimationUnrecPtr anim = getAnimation();
    anim->detachUpdateProducer();
    anim->removeAnimationListener(&theInternalAnimationListener);
    Inherited::finished();
}
コード例 #16
0
ファイル: SpriteAnimator.cpp プロジェクト: hakase-labs/hikari
    void SpriteAnimator::update(float delta) {
        Animator::update(delta);

        if(const auto& animation = getAnimation()) {
            const auto& currentFrame = animation->getFrameAt(getCurrentFrameIndex());
            const auto& currentFrameRectangle = currentFrame.getSourceRectangle();

            sourceRectangle.top = currentFrameRectangle.getTop();
            sourceRectangle.width = currentFrameRectangle.getWidth();
            sourceRectangle.height = currentFrameRectangle.getHeight();
            sourceRectangle.left = currentFrameRectangle.getLeft();

            sprite.setTextureRect(sourceRectangle);
        
            sprite.setOrigin(
                static_cast<float>(currentFrame.getHotspot().getX()),
                static_cast<float>(currentFrame.getHotspot().getY())
            ); 

            if(invertXOffset) {
                sprite.setOrigin(
                    static_cast<float>(currentFrame.getSourceRectangle().getWidth() - currentFrame.getHotspot().getX()),
                    static_cast<float>(sprite.getOrigin().y)
                ); 
            } 

            if(invertYOffset) {
                sprite.setOrigin(
                    static_cast<float>(sprite.getOrigin().x),
                    static_cast<float>(currentFrame.getSourceRectangle().getHeight() - currentFrame.getHotspot().getY())
                ); 
            }
        }
    }
コード例 #17
0
ファイル: spr_tools.c プロジェクト: kubilus1/SGDK
spriteDefinition_* getSpriteDefinition(unsigned char *image8bpp, int w, int h, int wf, int hf, int time, int collision)
{
    int i;
    int numAnim;
    spriteDefinition_* result;
    animation_** animations;

    // get number of animation
    numAnim = h / hf;

    // allocate result
    result = malloc(sizeof(spriteDefinition_));
    result->numAnimation = numAnim;
    // allocate animation array
    animations = malloc(numAnim * sizeof(animation_*));
    result->animations = animations;

    for(i = 0; i < numAnim; i++)
    {
        *animations = getAnimation(image8bpp, w, i, wf, hf, time, collision);
        if (*animations == NULL) return NULL;
        animations++;
    }

    return result;
}
コード例 #18
0
ファイル: Rolelayer.cpp プロジェクト: SongCF/game-CoolRun
void Rolelayer::playAnimationByname(Node *bs,std::string jsonfile,std::string filename,std::string animationName,bool isloop,bool isscal,Vec2 p){

	auto armature =Armature::create(filename.c_str());
	if(isloop==true){
		armature->getAnimation()->play(animationName.c_str(),-1,1);
	}
	armature->removeFromParentAndCleanup(true);
	armature->setPosition(p);
	armature->setTag(100);
	armature->setLocalZOrder(100);
	bs->addChild(armature);
	//xx_sly
	if(getUnitTypeByArmatureName(filename) == unittype_Actor){
		auto yinying_img=Sprite::create(hero_yingyin_img); //(hero_yingyin_img);
		yinying_img->setAnchorPoint(Vec2(0.5,0));
		yinying_img->setScaleX(1.5f);
		yinying_img->setPosition(Vec2(p.x,-armature->getContentSize().height/2+40));
		bs->addChild(yinying_img);
// 		xkongz.xx_action=armature;
// 		xkongz.time=0;
// 		xkongz.xxtime[0]=20;
// 		xkongz.xxtime[1]=1;
// 		xkongz.change=false;
	}
	else if(getUnitTypeByArmatureName(filename) == unittype_Pet){
		auto yinying_img=Sprite::create(hero_yingyin_img); //(hero_yingyin_img);
		yinying_img->setAnchorPoint(Vec2(0.5,0));
		yinying_img->setPosition(Vec2(p.x,-armature->getContentSize().height/2+30));
		bs->addChild(yinying_img);
	}
	else if(getUnitTypeByArmatureName(filename) == unittype_Magic){
		armature->setScale(0.5f);
	}
}
コード例 #19
0
ファイル: UnstableTile.cpp プロジェクト: MORTAL2000/Cendric2
void UnstableTile::loadAnimation(int skinNr) {
	m_isCollidable = true;

	Animation* idleAnimation = new Animation(sf::seconds(10.f));
	idleAnimation->setSpriteSheet(g_resourceManager->getTexture(ResourceID::Texture_tile_unstable));
	idleAnimation->addFrame(sf::IntRect(BORDER, BORDER + ((skinNr - 1) * (TILE_SIZE + 2 * BORDER)), TILE_SIZE, TILE_SIZE));

	addAnimation(GameObjectState::Idle, idleAnimation);

	Animation* tremblingAnimation = new Animation(sf::seconds(0.1f));
	tremblingAnimation->setSpriteSheet(g_resourceManager->getTexture(ResourceID::Texture_tile_unstable));
	tremblingAnimation->addFrame(sf::IntRect(BORDER + 1 * (2 * BORDER + TILE_SIZE), BORDER + ((skinNr - 1) * (TILE_SIZE + 2 * BORDER)), TILE_SIZE, TILE_SIZE));
	tremblingAnimation->addFrame(sf::IntRect(BORDER + 2 * (2 * BORDER + TILE_SIZE), BORDER + ((skinNr - 1) * (TILE_SIZE + 2 * BORDER)), TILE_SIZE, TILE_SIZE));

	addAnimation(GameObjectState::Trembling, tremblingAnimation);

	Animation* crumblingAnimation = new Animation();
	crumblingAnimation->setSpriteSheet(g_resourceManager->getTexture(ResourceID::Texture_tile_destructible));
	for (int i = 1; i < 5; i++) {
		crumblingAnimation->addFrame(sf::IntRect(
			BORDER + i * (2 * BORDER + TILE_SIZE),
			BORDER,
			TILE_SIZE,
			TILE_SIZE));
	}

	addAnimation(GameObjectState::Crumbling, crumblingAnimation);

	// initial values
	m_state = GameObjectState::Idle;
	setCurrentAnimation(getAnimation(GameObjectState::Idle), false);
	playCurrentAnimation(true);
}
コード例 #20
0
void Enemy::moveUp(int px)
{
	Action GoUp;
	GoUp.is_blocking = true;
	GoUp.thread_id = 1;
	Action AnimReset;
	AnimReset.is_blocking = true;
	AnimReset.thread_id = 1;

	GoUp.action = get_action([this, px](sf::Time dt)
	{
		if (getAnimationState() != static_cast<int>(Animations::GoUp))
		{
			animation.play();
			changeAnimation(static_cast<int>(Animations::GoUp));
			getAnimation().play();
		}
		return goUpUntil(px, dt);
	});

	AnimReset.action = get_action([this](sf::Time dt)
	{
		animation.reset();
		return false;
	});

	action_tree.push(GoUp);
	action_tree.push(AnimReset);
}
コード例 #21
0
 void CCDragonBones::gotoAndPlay(
     const String &animationName,
     Number fadeInTime,
     Number duration,
     Number loop,
     uint layer,
     const String &group,
     const String &fadeOutMode,
     bool displayControl,
     bool pauseFadeOut,
     bool pauseFadeIn
     )
 {
     getAnimation()->gotoAndPlay(animationName,
         fadeInTime,
         duration,
         loop,
         layer,
         group,
         fadeOutMode,
         displayControl,
         pauseFadeOut,
         pauseFadeIn
         );
 }
コード例 #22
0
ファイル: APArmSpeedAction.cpp プロジェクト: Zoyak/APLib
//计算差值变量
void APArmSpeedAction::startWithTarget(Node *target){
    ActionInterval::startWithTarget(target);
    //获取默认速度
    auto p_target=dynamic_cast<Armature*>(target);
    m_startSpeed=p_target->getAnimation()->getSpeedScale();
    //计算速度变量
    m_deltaSpeed=m_endSpeed-m_startSpeed;
}
コード例 #23
0
void ComponentSpine::addAnimation(const graphics::SpineManagerItem * _animation, const int track_index, const bool loop, const float delay)
{
    auto __animation = * const_cast<graphics::SpineManagerItem *>(_animation);

    updateSpine(__animation);

    spAnimationState_addAnimation(animationState, track_index, __animation.getAnimation(), loop, delay);
}
コード例 #24
0
ファイル: APArmSpeedAction.cpp プロジェクト: Zoyak/APLib
//帧改变动画速率
void APArmSpeedAction::update(float time){
    ActionInterval::update(time);
    auto target=dynamic_cast<Armature*>(getTarget());
    if (getTarget()) {
        //改变动画速率
        target->getAnimation()->setSpeedScale(m_startSpeed+m_deltaSpeed*time);
    }
}
コード例 #25
0
ファイル: ExplosionEntity.cpp プロジェクト: bYemma/MMP2016
void ExplosionEntity::initAnimations()
{
	auto frames = getAnimation("explosion/%02d.png", 14);
	sprite = Sprite::createWithSpriteFrame(frames.front());
	auto animate = Animate::create(Animation::createWithSpriteFrames(frames, 1.0f / 20));
	auto fadeOut = FadeOut::create(14 * 1.0f / 20);
	animation = Spawn::createWithTwoActions(animate, EaseIn::create(fadeOut, 1.0f));
	animation->retain();
}
コード例 #26
0
//强化按钮
void EquipUpgradeLayer::upgradeBtn_OnTouch(Ref* sender, Widget::TouchEventType type)
{
    if (type!=Widget::TouchEventType::ENDED) return;
    SoundBLL::getInstance()->playEffect(kButtonSound);
    auto btn=(ui::Button*)sender;
    btn->setTouchEnabled(false);
    
    int equipId=btn->getTag();
    auto equip=&(equiplocalBll->modelData[equipId]);
    
    //读取玩家金币数据
    auto pbb = PlayerBLL::create();
    auto gold = pbb->getPlayerGold();
    if (gold<equip->UpPrice) {
        PopTipsLayer::addTipLayer(this, "金币不足!");
        btn->setTouchEnabled(true);
        return;
    }
    
    pbb->addGold(-equip->UpPrice);
    //升级装备
    equiplocalBll->upEquip(equipId);
    //本地英雄数据
    HeroBase *h2 = GameObjectFactory::getHero(currSelectHeroID-1);
    auto mod = h2->getHeroModel();
    //更新英雄属性
    equiplocalBll->updateHeroAttribute(mod->HeroID-1);
    //重新取本地数据
    h2 = GameObjectFactory::getHero(currSelectHeroID-1);
    mod = h2->getHeroModel();
    //更新显示属性
    updateInfo(mod);
    
    equip=&(equiplocalBll->modelData[equipId]);
    auto att = equiplocalBll->getEquipChineseName(equipId);
    std::string strDes=StringUtils::format("Lv.%d \n%s",equip->CurrLv,att.c_str());
    std::string strName=StringUtils::format("%s",equip->WeaponName);
    t_backpackDes->setString(strDes);
    t_wearitemname->setString(strName);
    s_wearborder->setVisible(false);
    
    auto effect=Armature::create("anxt_ui");
    effect->setPosition(btn->getPosition() - Vec2(292, 0));
    auto parent=btn->getParent();
    parent->addChild(effect);
    effect->getAnimation()->play("ui_1");
    
    auto func=[&](){
        //刷新装备物品
        showWearpack();
    };
    effect->runAction(Sequence::create(DelayTime::create(0.5),CallFunc::create(func),RemoveSelf::create(), NULL));
    
    if (updateCalllback) {
        updateCalllback(this);
    }
}
コード例 #27
0
ファイル: AnimationManager.cpp プロジェクト: Windyzjw/FallMan
//获取一个指定动画模版的实例
CCAnimate* AnimationManager::createAnimate(int key){
	//获取指定动画模版
	CCAnimation* anim = getAnimation(key);
	if(anim){
		//根据动画模版生成一个动画实例
		return cocos2d::CCAnimate::create(anim);
	}
	return NULL;
}
コード例 #28
0
ファイル: Player.cpp プロジェクト: Clever-Boy/mario
void Player::draw(Map* map) {
	SDL_Rect bb = getBoundingBox(map);
	Animation& animation = getAnimation();

	SDL_Rect animationRect = animation.getStep();

	TextureStore* store = GameEngine::getInstance().getTextureStore();
	SDL_RenderCopy(GameEngine::getInstance().getRenderer(), store->getOrLoadTexture(player_texture_path), &animationRect, &bb);
}
コード例 #29
0
void LevelMainCharacter::load()
{
	setBoundingBox(sf::FloatRect(0.f, 0.f, 30.f, 100.f));
	setSpriteOffset(sf::Vector2f(-25.f, -20.f));

	Animation walkingAnimation;
	walkingAnimation.setSpriteSheet(g_resourceManager->getTexture(ResourceID::Texture_mainChar));
	walkingAnimation.addFrame(sf::IntRect(0, 0, 80, 120));
	walkingAnimation.addFrame(sf::IntRect(80, 0, 80, 120));
	walkingAnimation.addFrame(sf::IntRect(160, 0, 80, 120));
	walkingAnimation.addFrame(sf::IntRect(240, 0, 80, 120));
	walkingAnimation.addFrame(sf::IntRect(320, 0, 80, 120));
	walkingAnimation.addFrame(sf::IntRect(400, 0, 80, 120));
	walkingAnimation.addFrame(sf::IntRect(480, 0, 80, 120));
	walkingAnimation.addFrame(sf::IntRect(560, 0, 80, 120));

	addAnimation(GameObjectState::Walking, walkingAnimation);

	Animation idleAnimation;
	idleAnimation.setSpriteSheet(g_resourceManager->getTexture(ResourceID::Texture_mainChar));
	idleAnimation.addFrame(sf::IntRect(640, 0, 80, 120));

	addAnimation(GameObjectState::Idle, idleAnimation);

	Animation jumpingAnimation;
	jumpingAnimation.setSpriteSheet(g_resourceManager->getTexture(ResourceID::Texture_mainChar));
	jumpingAnimation.addFrame(sf::IntRect(720, 0, 80, 120));

	addAnimation(GameObjectState::Jumping, jumpingAnimation);

	Animation fightingAnimation;
	fightingAnimation.setSpriteSheet(g_resourceManager->getTexture(ResourceID::Texture_mainChar));
	fightingAnimation.addFrame(sf::IntRect(800, 0, 80, 120));
	fightingAnimation.addFrame(sf::IntRect(880, 0, 80, 120));
	fightingAnimation.addFrame(sf::IntRect(960, 0, 80, 120));
	fightingAnimation.addFrame(sf::IntRect(1040, 0, 80, 120));
	fightingAnimation.addFrame(sf::IntRect(1040, 0, 80, 120));

	addAnimation(GameObjectState::Fighting, fightingAnimation);

	Animation deadAnimation;
	deadAnimation.setSpriteSheet(g_resourceManager->getTexture(ResourceID::Texture_mainChar));
	deadAnimation.addFrame(sf::IntRect(1120, 0, 80, 120));

	addAnimation(GameObjectState::Dead, deadAnimation);

	setFrameTime(sf::seconds(0.07f));

	// initial values
	m_state = GameObjectState::Idle;
	m_isFacingRight = true;
	setCurrentAnimation(getAnimation(m_state), !m_isFacingRight);
	playCurrentAnimation(true);

	setDebugBoundingBox(sf::Color::White);
}
コード例 #30
0
ファイル: model.cpp プロジェクト: Hellzed/xoreos
void Model::populateDefaultAnimations() {
	_defaultAnimations.clear();

	// TODO: There's probably a cleaner way to do this, but it's late
	for (int i = 0; i < 9; i++) {
		Animation *anim = getAnimation(kDefaultAnims[i]);
		if (anim)
			_defaultAnimations.push_back(anim);
	}
}