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

Author Topic: The way to animate  (Read 1753 times)

0 Members and 1 Guest are viewing this topic.

Valiunia

  • Newbie
  • *
  • Posts: 9
    • View Profile
    • Email
The way to animate
« on: June 28, 2013, 01:16:01 pm »
HI guys!

I was looking for a way to make animation of my game, where I have player image, i googled for hours to find an understandable way of making animation, I have tried Thor, but I dont understand a thing on how to use it, and documentation didnt helped me,

ANYWAYS,

I came up with this:

3 images, each one is changing if (sf::Keyboard::isKeyPressed(sf::Keyboard::A))

BUT to make them change NOT every frame i did this :

   if (sf::Keyboard::isKeyPressed(sf::Keyboard::A))
         {
            
            bb++;
            
            CC= bb % 10;
            if (!CC)
            // IMAGE CHANGES TO NEXT
         }

What it does, is adds +1 to int bb
CC is equal to MODULUS of bb

SO, every 10 loops CC != 0
when that happens image changes

so images are changing every 10 frames

what do you think of this method? Is it okay to use? If its not can you advice something ? I did this coz im kinda desperate  :'(

Valiunia

  • Newbie
  • *
  • Posts: 9
    • View Profile
    • Email
Re: The way to animate
« Reply #1 on: June 28, 2013, 06:31:24 pm »
Ok, i have tested it for a few minutes, it seems to be working very good and its also easy to adjust how often do you need to change images, i guess this is a good way to animate things :P

Geheim

  • Full Member
  • ***
  • Posts: 201
    • View Profile
    • Email
Re: The way to animate
« Reply #2 on: June 28, 2013, 06:49:11 pm »
You should use a timer for your animations, because now it runs not on every computer at the same speed!
Just increase/decrease a float with your frametime, if you press the key and if it hits either a value or 0, reset your timer and change your frame ;)
Failing to succeed does not mean failing to progress!

 

anything