Android 播放声音会给精灵造成延迟';s动画

Android 播放声音会给精灵造成延迟';s动画,android,opengl-es,andengine,Android,Opengl Es,Andengine,我使用AndEngine库创建了android实时墙纸应用程序。墙纸有一个带有声音的摆动动画 问题是每次播放摆动声音时,摆动动画都会延迟几毫秒 我想知道有没有解决办法?我曾尝试创建一个线程来播放声音,但结果仍然滞后 代码是这样的 public class TreeSwingSprite extends AnimatedSprite implements IAnimationListener, IEntityModifierListener { ... private

我使用AndEngine库创建了android实时墙纸应用程序。墙纸有一个带有声音的摆动动画

问题是每次播放摆动声音时,摆动动画都会延迟几毫秒

我想知道有没有解决办法?我曾尝试创建一个线程来播放声音,但结果仍然滞后

代码是这样的

public class TreeSwingSprite extends AnimatedSprite 
    implements IAnimationListener, IEntityModifierListener {

    ...
    private Sound swingSound;

    // this event happened when user touch the Sprite on screen
    public boolean onAreaTouched(TouchEvent pSceneTouchEvent, float pTouchAreaLocalX, float pTouchAreaLocalY) {
        if (pSceneTouchEvent.isActionDown()) {
            ...

            long[] frameDuration = new long[] {                                            
                50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
                ...
            };

            final int[] frame = {                             
                10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 
                ...
            };

            animate(frameDuration, frame, 0, this); // this code execute the animation of the Sprite

            // play the sound
            new Thread(new Runnable() {

                @Override
                public void run() {
                    if (swingSound != null) swingSound.play();
                }
            }).start();

    }
}

如果你不懂安引擎,纯openGL ES解决方案也可以。

不过,延迟的原因是特定设备没有强大的硬件支持,可能是处理器。我知道这一点,因为当我尝试使用其他设备时,它运行良好。

不需要在新线程上播放声音