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

Author Topic: sf::Coach - header-only extension for managing animations  (Read 2092 times)

0 Members and 1 Guest are viewing this topic.


  • Jr. Member
  • **
  • Posts: 87
    • View Profile
sf::Coach - header-only extension for managing animations
« on: April 05, 2017, 10:10:41 pm »
Hello. I came here to share my extension - sfCoach. I created it for personal needs, but maybe it will be useful for someone. So it helps you to animate objects.

Short documentation
There are 2 main classes: Animation and Coach in sfCoach namespace. The first one is abstract calss and has an update() method. The second one is just a simple container. Let's create a circle:
sf::CircleShape shape(50);
shape.setPosition(150, 150);

Now, you need to create instance of Coach class:
sfCoach::Coach coach;

Also, you should call Coach update() method every frame:
while (window.isOpen) {
  //Handle events....




Now you can animate your objects. You can animate: Sprite, Text, CircleShape, RectangleShape. Currently, there are 3 types of animation: DisplayAnimation, FadeAnimation, MoveAnimation.

DisplayAnimation hides or shows the target after specified amount of time.
FadeAnimation fades the target in or out.
MoveAnimation moves object from point A to point B (interpolation).

Creating animation (for example):
sfCoach::DisplayAnimation hide(sfCoach::createTarget(shape), 3.2f); //3.2f is delay in seconds after which shape will be hidden

sfCoach::createTarget is a factory method. It is overloaded for most drawables to create universal animatable targets.

The last step is simple: play it!

You can find example and source code in GitHub repository:


Thanks to therocode for factory methods idea