velocity - 和发动机路径修正速度

标签 velocity andengine sprite

我有以下代码,让 Sprite 可以使用 Andengine 遵循路径。我需要改变 Sprite 沿着 path() 移动的速度(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]);
}

最佳答案

您只能给出移动的持续时间,每个路径修饰符 1。因此,如果您希望在不同的路径点有不同的速度,则必须创建不同的路径修改器。

关于velocity - 和发动机路径修正速度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8906959/

相关文章:

ios - Cocos2d 2.0 : vertices and sprites

python - Pygame 中的平滑键盘移动

Java:花括号上的 Apache Velocity 解析器错误

java - 减去日期并恢复和速度

java - 如何在速度工具中获取 HttpServletRequest?

android - Andengine动态壁纸中的空指针异常

python - Pygame - 防止 Sprite 重叠

java - Velocity - #springFormInput 和自定义 ID

android - 无法在 AndEngine 中加载 Sprite

android - 如何在用户启动我的应用程序时弹出 'new update available' 对话框(android)