I have a vecotr of bullets in my player class. A bullet is created when the user clicks the spacebar. When it's created, I have two loops that call the bullet's Update() and Draw() function, respectively. In the update function there is a function that updates the sprite's animation.
I'm using the SFML Animation classes (
https://github.com/SFML/SFML/wiki/Source%3A-AnimatedSprite)
Here is the code that's giving me a problem:
bullet.cpp:
void Bullet::Update()
{
Move();
sprite.update(frameClock.restart());
}
+
and in the player.cpp:
void Player::Move()
{
for(int i = 0; i < bullets.size(); i++)
{
bullets[i].Update();
}
sprite.move(0, velocity.y);
}
Everything works UNTIL I PUT IN THE
sprite.update(frameClock.restart());
IT GIVES THE ERROR.
Does anyone know why?
edit:
here's the sprite.Update() source code from git:
oid AnimatedSprite::update(sf::Time deltaTime)
{
// if not paused and we have a valid animation
if(!m_isPaused && m_animation)
{
// add delta time
m_currentTime += deltaTime;
// if current time is bigger then the frame time advance one frame
if(m_currentTime >= m_frameTime)
{
// reset time, but keep the remainder
m_currentTime = sf::microseconds(m_currentTime.asMicroseconds() % m_frameTime.asMicroseconds());
// get next Frame index
if(m_currentFrame + 1 < m_animation->getSize())
m_currentFrame++;
else
{
// animation has ended
m_currentFrame = 0; // reset to start
if(!m_isLooped)
{
m_isPaused = true;
}
}
// set the current frame, not reseting the time
setFrame(m_currentFrame, false);
}
}
}