Note that there are some explanatory texts on larger screens.

plurals
  1. POandengine pathmodifier velocity
    text
    copied!<p>I have the following code for a sprite to follow a path using Andengine. I need to change the speed (velocity) of the sprites moving along the path(). Does anyone know how to vary the velocity along a path?</p> <pre><code>private void follow_path5(final AnimatedSprite tSprite,int i) { final Path path = new Path(5) .to(20, startY) .to(416.0f, startY) .to(20.0f, startY) .to(416.0f,startY) .to(20.0f,startY); // Add the proper animation when a waypoint of the path is passed. tSprite.registerEntityModifier(new PathModifier(30.0f, path, null, new IPathModifierListener() { @Override public void onPathStarted(final PathModifier pPathModifier, final IEntity pEntity) { } @Override public void onPathWaypointStarted(final PathModifier pPathModifier, final IEntity pEntity, final int pWaypointIndex) { switch(pWaypointIndex) { case 0: case 1: case 2: case 3: final long[] frameDurations = new long[3]; Arrays.fill(frameDurations, 500); tSprite.animate(frameDurations, 2, 4, true); break; case 4: case 5: case 6: case 7: final long[] frameDurations1 = new long[3]; Arrays.fill(frameDurations1, 500); tSprite.animate(frameDurations1, 5, 7, true); break; case 8: case 9: case 10: case 11: final long[] frameDurations2 = new long[3]; Arrays.fill(frameDurations2, 500); tSprite.animate(frameDurations2, 2, 4, true); break; case 12: case 13: case 14: final long[] frameDurations3 = new long[3]; Arrays.fill(frameDurations3, 500); tSprite.animate(frameDurations3, 5, 7, true); break; } } @Override public void onPathWaypointFinished(final PathModifier pPathModifier, final IEntity pEntity, final int pWaypointIndex) { } @Override public void onPathFinished(final PathModifier pPathModifier, final IEntity pEntity) { }})); scene.attachChild(asprVamp[i]); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload