I'd like to know how I could make a slideDown animation in C++ using SDL.

How would I implement the animation in SDL?

  • 1
    \$\begingroup\$ What have you tried? Why do you think you couldn't? What do you want to slide? Currently your question shows no research effort. \$\endgroup\$ – Tyyppi_77 Jul 31 '17 at 21:21

Basically, the key feature here to use are destination rectangles and render textures. You'll want to render your element that you want to slide into a render texture at full scale. Then for the actual animation, you need to render the render texture onto the screen with a destination rectangle. All you have to do is to update the height of the rectangle on an interval which is trivial to do.

If the sliding needs to affect elements below, you need to consider the height of the destination rectangle when calculating positions.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.