This seems like you want to manipulate the position and rotation of objects over time. AFAIK sfml does not provide this functionality out of the box, but it should be pretty easy and straightforward to implement this on your own.
I once built a similar solution for a three dimensional simulation, but it should translate well to a 2D graphical application.
First of you have two concepts: the Manipulator
and the according ManipulatorManager
. Manipulator
is an abstract base class for all kinds of manipulations of a specific object, for example a sprite. Manipulated can be all properties like position or rotation, move on a path or anything similar. The Manager
watches the state of the Manipulators
and updates them every frame.
The interface for the manipulator looks something like that:
class Manipulator {
public:
Manipulator(float expiration_time) : expiration_time(expiration_time);
bool is_expired() { return expiration_time < 0.f; }
void update(float dt) { this->expiration_time -= dt; }
protected:
float expiration_time;
}
An implementation of this class is the SimpleLineManipulator
which influences the position of a sprite over a certain time on a straight line:
class SimpleLineManipulator {
SimpleLineManipulator(Sprite *spr, Vector2f begin, Vector2f end, float expiration_time);
...
private:
Sprite* sprite;
Vector2f begin, end;
float total_time; // initialized with expiration_time
}
And this is how the update method looks like (where the most of the work takes place):
void SimpleLineManipulator::update(float dt) {
Manipulator::update(dt);
Vector2f position = lerp(end, begin, total_time/expiration_time);
spr->SetPosition(position.x, position.y);
}
All you have to do now is call the update()
method every frame.
It should be easy to implement a rotatory manipulator or manipulators that work on a path (a list of positions). You can now also combine these manipulators to create combined effects.
I hope I could outline the architecture in a clear manner. Feel free to ask :)