显示错误方法setNeedsSound(boolean)未定义EngineOptions类型

时间:2012-09-27 12:41:13

标签: android andengine

public EngineOptions onCreateEngineOptions() {
    instance = this;
    mCamera = new Camera(0, 0, CAMERA_WIDTH, CAMERA_HEIGHT);

    return new EngineOptions(true, ScreenOrientation.LANDSCAPE_FIXED,
            new RatioResolutionPolicy(CAMERA_WIDTH, CAMERA_HEIGHT), mCamera)).setNeedsSounds(true);
}

在启用声音时显示错误,显示错误 对于EngineOptions类型

,方法setNeedsSound(boolean)未定义

也尝试了

return new EngineOptions(true, ScreenOrientation.LANDSCAPE_FIXED,
                new RatioResolutionPolicy(CAMERA_WIDTH, CAMERA_HEIGHT), mCamera)).getAudioOptions().setNeedsSound(true);

但显示错误 类型不匹配:无法从AudioOptions转换为EngineOptions

2 个答案:

答案 0 :(得分:0)

以这种方式试试

final EngineOptions engineOptions = new EngineOptions(true, ScreenOrientation.LANDSCAPE_FIXED,
            new RatioResolutionPolicy(CAMERA_WIDTH, CAMERA_HEIGHT), mCamera);
    engineOptions.getAudioOptions().setNeedsSound(true);
    engineOptions.getAudioOptions().setNeedsMusic(true);

答案 1 :(得分:0)

您的代码中似乎有额外的)。尝试:

return new EngineOptions(true, ScreenOrientation.LANDSCAPE_FIXED, new RatioResolutionPolicy(CAMERA_WIDTH, CAMERA_HEIGHT), mCamera).setNeedsSounds(true);