Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - comwizz2

Pages: [1]
1
Graphics / TextureRect not updating?
« on: July 03, 2013, 07:44:05 pm »
I don't know what I'm doing wrong but for some reason I cannot seem to get my animated sprite to change frames. :/ The initial Sprite.setTextureRect works fine, but every one I try to call in my loop seems to have no effect.

I was hoping to get a little insight from people more experienced than I.


Update Function
void AnimatedObject::Update(float Delta)
{
    PassedTime += Delta;
    if (PassedTime >= TimePerFrame)
    {
        PassedTime -= TimePerFrame;
        CurrentFrame++;
        if(CurrentFrame > LastFrame)
        {
            CurrentFrame = InitialFrame;
        }
        Sprite.setTextureRect( FindOffset(CurrentFrame,FrameSize,TextureSize) );
    }
    Location += sf::Vector2f(Delta,Delta);
}
 
Draw Function
void Object::Draw(sf::RenderWindow* Win)
{
    Sprite.setPosition(Location);
    Win->draw(Sprite);
}
 

I've done my own debugging and the setTextureRec is getting called with valid values (0,0,20,20) and (0,20,20,20) But it only ever shows the first frame. even thought that line is getting executed.
Calling setTextureRect in the constructor DOES work though... so I'm puzzled. I'm sure its just operator error, but for the life of me I can't figure it out.

Pages: [1]
anything