Q:

Moving a sprite using a complex mathematical path in AndEngine

I'm new to AndEngine programming. I want to move a sprite recreating a complex animation before the user can interact with it.
The initial movement of the sprite is not so linear and not so simple. I want to apply a complex Mathematical algorithm to the coordinates of the moving sprite.
How can I achieve this ? Which existing functions can I use in AndEngine ?

A:

Calculate your positions and store them into two float arrays. Each cell in the first array would be a X coordinate, and in the second array it would be a Y coordinate.
Then, create a Path object. Make sure it is AndEngine's Path object, not the regular Android SDK one (AndEngine one is org.anddev.andengine.entity.modifier.PathModifier.Path).
Create your Path this way:
Path path = new Path(coordinatesX, coordinatesY);

Where coordinatesX and coordinatesY are, of course, float arrays.
Now, all you have to do is create a PathModifier with your Path:
PathModifier modifier = new PathModifier(duration, path);
modifier.setRemoveWhenFinished(true);

(duration is a float specifying the time for the entity will move along the path. The smaller it is, the faster the entity moves. Experiment with different times to find out what works the best for you).
Calling setRemoveWhenFinished with a true argument makes sure the path modifier will be unregistered when the path is completed.
Then just register it to your sprite:
sprite.registerEntityModifier(modifier);

And you are done.

