Andengineを使ってパスに従うスプライトのコードは次のとおりです。パスに沿って移動するスプライトの速度(速度)を変更する必要があります()。誰かが経路に沿って速度を変える方法を知っていますか?andengine pathmodifier velocity
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]);
}
私は部分的にスプライトが動作しますが、少しぎくしゃくアニメーション – ITECH
何素敵なハックを生成し、ランダムな間隔で走行しているの経路に沿って負の方向に少し移動する別のパスを実行するために)(実行可能を使用してこれを解決しました私は決してこれについて考えなかったでしょう:-) – JohnEye