AndEngine mEngine 空引用?

AndEngine mEngine null reference?

我在 Android Studio 上遇到一些样板代码的问题。我通过调试器 运行 发现 mEngine 未初始化并且正在作为空值访问。我正在关注本教程: http://www.makethegame.net/android-andengine/how-to-setup-andengine-with-android-studio/

我不知道如何解决这个错误,因为我不知道如何初始化 mEngine。有什么建议吗?

public class gameplay extends LayoutGameActivity {

    //AndEngine variables//
    private Camera camera;
    private int CAMERA_WIDTH = 320;
    private int CAMERA_HEIGHT = 480;
    public Scene currentScene;
    //End of AndEngine variables//

    //AndEngine boiler plate code//
    @Override
    protected int getLayoutID() {
        return R.layout.activity_gameplay;
    }

    @Override
    protected int getRenderSurfaceViewID() {
        return R.id.gameView;
    }

    @Override
    public EngineOptions onCreateEngineOptions() {
        this.camera = new Camera(0,0, CAMERA_WIDTH, CAMERA_HEIGHT);
        EngineOptions engineOptions = new EngineOptions(true, ScreenOrientation.PORTRAIT_FIXED, new FillResolutionPolicy(), camera);
           engineOptions.getAudioOptions().setNeedsMusic(true).setNeedsSound(true);
        engineOptions.setWakeLockOptions(WakeLockOptions.SCREEN_ON);
        return engineOptions;
    }

    @Override
    public void onCreateResources(OnCreateResourcesCallback pOnCreateResourcesCallback) throws IOException {
        pOnCreateResourcesCallback.onCreateResourcesFinished();
    }

    //ERROR IN THIS METHOD BELOW
    @Override
    public void onCreateScene(OnCreateSceneCallback pOnCreateSceneCallback) throws IOException {
        mEngine.registerUpdateHandler(new FPSLogger());
        //Attempt to read from field 'org.andengine.engine.Engine org.andengine.opengl.view.EngineRenderer.mEngine' on a null object reference
        currentScene = new Scene();
        currentScene.setBackground(new org.andengine.entity.scene.background.Background(0.09804f, 0.7274f, 0.8f));
    }

    @Override
    public void onPopulateScene(Scene pScene, OnPopulateSceneCallback pOnPopulateSceneCallback) throws IOException {
        pOnPopulateSceneCallback.onPopulateSceneFinished();
    }
    //End of AndEngine boiler plate code//
}

下面附上我的错误日志:

您是否有必要延长LayoutGameActivity。 请尝试 BaseGameActivity

尝试 运行 你的错误行 mEngine.registerUpdateHandler(new FPSLogger());OnPopulateScene.