This example show how a sprite can follow a path.
You can use the
ol.Sprite.setPath() to set the path to follow. Then just call
ol.Sprite.move()
in the game loop to have the sprite moving along the path.
Use
ol.Sprite.stop() and
ol.Sprite.restart() to control the movement.
Listen to :
-
change:direction event to know when the sprite take a new segment
-
destination event to know when the sprite reach the final destination.