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 - lumiet

Pages: [1]
1
Graphics / Re: Animation Issue
« on: March 25, 2017, 03:57:21 pm »
Managed to fix it by doing this instead:
if (sec.getElapsedTime().asSeconds() > .25) {
                        lucinaselection = spriteanimation(lucinasprite, lucinaselection);
                        lucinasprite.setTextureRect(lucinaselection);
                        sec.restart();
                }
Still don't know why my original didn't work, but hey. I'll take what I can get.

2
Graphics / Animation Issue
« on: March 24, 2017, 10:49:51 pm »
Let me preface this by saying that I am by no means a professional at C++ or SFML, and I'm probably just doing something stupid.
Here's an excerpt of what I have:
IntRect spriteanimation(Sprite sprite, IntRect selection) {    
        //every 1/4 second, move an image right on the sprite sheet- if its at the end
        //of the animation, reset to initial position
        if (selection.left >= 32 * 3) {
                selection.left = 0;
        }
        else {
                selection.left += 32;
        }
       
        if (isspritehovered(sprite) == true && selection.top <= 32) {
                        selection.top += 32;
                }
                else if (selection.top > 0) {
                        selection.top -= 32;
                }
       
                return selection;      
}
void main() {
while (renderWindow.isOpen()) {

if (sec.getElapsedTime().asSeconds() > .25) {
                        henrysprite.setTextureRect(spriteanimation(henrysprite, henryselection));
                        lucinasprite.setTextureRect(spriteanimation(lucinasprite, lucinaselection));
                        sec.restart();
                }
renderWindow.draw(henrysprite);
renderWindow.draw(lucinasprite);
}
}
 
      
Now, what I can't understand is that moving the selection down 32 works perfectly fine and affects the animation, but moving the selection left doesn't work at all. Any help would be much appreciated. I'm a beginner, so go easy on me please.

Pages: [1]
anything