在背景中加载 - AndEngine GLES2

时间:2012-02-17 12:03:08

标签: android android-asynctask andengine

我在AndEngine GLES2中移植我的项目,使用GLES1版本我使用此tutorial在后台加载资源,现在我收到此错误:

mActivity.onCreateScene failed. @(Thread: 'GLThread 10')
java.lang.ExceptionInInitializerError

这是我的onCreateScene方法

    @Override
    public Scene onCreateScene() {
        this.mEngine.registerUpdateHandler(new FPSLogger());
        SplashScene mSplashScene = new SplashScene(this);

        IAsyncCallback callback = new IAsyncCallback() {

            @Override
            public void workToDo() {
            //Do something}

            @Override
            public void onComplete() {
                LoadingScene mLoadingScene = new LoadingScene(mActivity.this);
                mActivity.this.getEngine().setScene(mLoadingScene);
            }
        };

        new AsyncTaskLoader().execute(callback);

        return mSplashScene;
    }

1 个答案:

答案 0 :(得分:5)

更改

new AsyncTaskLoader().execute(callback);

    //Fixed variant working with gles1 and gles2
    runOnUiThread(new Runnable() {
        @Override
        public void run() {
            new AsyncTaskLoader().execute(callback);
        }
    });