Button pressed query dependent on frame rate?

I want to make a simple game, where I need to press A to breed an egg. Now I noticed that my egg animation moves too fast with default frame rate settings. But then I set the frame rate lower it checks late if the a button was pressed, since its all in one method or function (Idk what it is called In c++). So whats the best way to query if a button was pressed without delay and draw animation slower?

You need to time your animation separately from your frame rate.
The way I usually do it is to count frames then change my animation frame every say 6 frames, instead of every frame.


animCount++;
if(animCount==6){
  animCount=0;
// animate image

}
3 Likes

After animating the image dont you need to reset the framecount ? Or else it would do it only once.

1 Like

Well spotted. I’d like to say I left that out to test you, but I was typing on my phone and forgot :non-potable_water:
code updated

1 Like

Yeah you need that, I noticed fast when I tried it. You also need to set gb.presistence to true since when you don’t draw each frame something it will clear the display each frame.