AndEngine. I use Path() and PathModifier() for my game.
path = new Path(2).to(10, 10).to(100, 100);
sprite.registerEntityModifier(new LoopEntityModifier(new PathModifier(1f, path, null, new IPathModifierListener() {
public void onPathStarted(final PathModifier pPathModifier, final IEntity pEntity) {
}
public void onPathWaypointStarted(final PathModifier pPathModifier, final IEntity pEntity, final int pWaypointIndex) {
}
public void onPathWaypointFinished(final PathModifier pPathModifier, final IEntity pEntity, final int pWaypointIndex) {
}
public void onPathFinished(final PathModifier pPathModifier, final IEntity pEntity) {
}
}, EaseSineInOut.getInstance())));
It works, but I dont't want endless loop for it. Then I changed method onPathFinished( ):
public void onPathFinished(final PathModifier pPathModifier, final IEntity pEntity) {
pEntity.clearEntityModifiers();
}
But after that my sprite have done 1 loop and return in first position (10,10) and stopped. So, how to make a stop in position (100,100) after 1 loop?
you should use yourSprite.setPosition(100,100)
in onPathFinished()