/*!
    Inserts a pause of \a msecs milliseconds at \a index in this animation
    group.

    \sa addPause(), QAnimationGroup::insertAnimation()
*/
QPauseAnimation *QSequentialAnimationGroup::insertPause(int index, int msecs)
{
    Q_D(const QSequentialAnimationGroup);

    if (index < 0 || index > d->animations.size()) {
        qWarning("QSequentialAnimationGroup::insertPause: index is out of bounds");
        return 0;
    }

    QPauseAnimation *pause = new QPauseAnimation(msecs);
    insertAnimation(index, pause);
    return pause;
}
/*!
    Adds \a animation to this group. This will call insertAnimation with
    index equals to animationCount().

    \note The group takes ownership of the animation.

    \sa removeAnimation()
*/
void QAnimationGroup::addAnimation(QAbstractAnimation *animation)
{
    Q_D(QAnimationGroup);
    insertAnimation(d->animations.count(), animation);
}
Ejemplo n.º 3
0
void Player::initAnimation()
{
	m_spriteSheet = new sf::Texture;
	if(!m_spriteSheet->loadFromFile("../data/sprites/hero_spritesheet.png")) printf("Player::initAnimation() somethings wrong\n");
	//Idle animation
	Animation* m_animator_idle = new Animation;
	m_animator_idle->setSpriteSheet(*m_spriteSheet);
	m_animator_idle->addFrame(sf::IntRect(0, 18, 80, 66));
	m_animator_idle->addFrame(sf::IntRect(80, 18, 80, 66));
	m_animator_idle->addFrame(sf::IntRect(160, 18, 80, 66));
	m_animator_idle->addFrame(sf::IntRect(240, 18, 80, 66));
	m_animator_idle->addFrame(sf::IntRect(320, 18, 80, 66));
	m_animator_idle->addFrame(sf::IntRect(400, 18, 80, 66));
	m_animator_idle->addFrame(sf::IntRect(480, 18, 80, 66));
	insertAnimation("idle", m_animator_idle);
	//walking animation
	Animation* m_animation_walking = new Animation;
	m_animation_walking->setSpriteSheet(*m_spriteSheet);
	m_animation_walking->addFrame(sf::IntRect(0, 115, 80, 66));
	m_animation_walking->addFrame(sf::IntRect(80, 115, 80, 66));
	m_animation_walking->addFrame(sf::IntRect(160, 115, 80, 66));
	m_animation_walking->addFrame(sf::IntRect(240, 115, 80, 66));
	m_animation_walking->addFrame(sf::IntRect(320, 115, 80, 66));
	m_animation_walking->addFrame(sf::IntRect(400, 115, 80, 66));
	insertAnimation("walking", m_animation_walking);
	//shoot/aim
	Animation* m_animation_shooting = new Animation;
	m_animation_shooting->setSpriteSheet(*m_spriteSheet);
	m_animation_shooting->addFrame(sf::IntRect(0, 210, 80, 66));
	m_animation_shooting->addFrame(sf::IntRect(80, 210, 80, 66));
	m_animation_shooting->addFrame(sf::IntRect(160, 210, 80, 66));
	m_animation_shooting->addFrame(sf::IntRect(240, 210, 80, 66));
	m_animation_shooting->addFrame(sf::IntRect(320, 210, 80, 66));
	m_animation_shooting->addFrame(sf::IntRect(400, 210, 80, 66));
	insertAnimation("shooting", m_animation_shooting);
	//jump
	Animation* m_animation_jump = new Animation;
	m_animation_jump->setSpriteSheet(*m_spriteSheet);
	//m_animation_jump->addFrame(sf::IntRect(0, 298, 80, 66));
	m_animation_jump->addFrame(sf::IntRect(80, 298, 80, 66));
	//m_animation_jump->addFrame(sf::IntRect(160, 298, 80, 66));
	//m_animation_jump->addFrame(sf::IntRect(80, 298, 80, 66));
	insertAnimation("jump", m_animation_jump);
	//die need to check coordinates
	Animation* m_animation_die = new Animation;
	m_animation_die->setSpriteSheet(*m_spriteSheet);
	m_animation_die->addFrame(sf::IntRect(240, 298, 80, 66));
	m_animation_die->addFrame(sf::IntRect(320, 298, 80, 66));
	m_animation_die->addFrame(sf::IntRect(400, 298, 80, 66));
	m_animation_die->addFrame(sf::IntRect(500, 298, 80, 66));
	insertAnimation("die", m_animation_die);
	//Duck (not the animal)
	Animation* m_animation_duck = new Animation;
	m_animation_duck->setSpriteSheet(*m_spriteSheet);
	m_animation_duck->addFrame(sf::IntRect(0, 396, 80, 56));
	//m_animation_duck->addFrame(sf::IntRect(80, 396, 80, 56));
	insertAnimation("duck", m_animation_duck);
	

	m_animatedSprite = (new AnimatedSprite(sf::seconds(0.2), true, true));
	m_animatedSprite->setPosition(400, 400);
	m_animatedSprite->setAnimation(*getAnimation("idle"));
}