AndEngine: Black screen when using LayoutGameActivity

Posted by Lemuel Hogben on Stack Overflow See other posts from Stack Overflow or by Lemuel Hogben
Published on 2012-10-19T10:57:57Z Indexed on 2012/10/19 11:00 UTC
Read the original article Hit count: 199

Filed under:
|

I used to use SimpleBaseGameActivity for my app and everything was ok, but now I want to add some ads into the app, so I tried to use LayoutGameActivity. But I get the screen completely black and I don't know why. That's my code:

public class AcGame extends LayoutGameActivity {
    [...]
    @Override
    protected int getLayoutID() {
        return R.layout.ad;
    }

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

    @Override
    public EngineOptions onCreateEngineOptions() {
        [...]
        return new EngineOptions(true, ScreenOrientation.PORTRAIT_FIXED, resolution, camera);
    }

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

    @Override
    public void onCreateScene(OnCreateSceneCallback pOnCreateSceneCallback) throws Exception {
        pOnCreateSceneCallback.onCreateSceneFinished(createScene());
    }

    @Override
    public void onPopulateScene(Scene pScene, OnPopulateSceneCallback pOnPopulateSceneCallback) throws Exception {
        pOnPopulateSceneCallback.onPopulateSceneFinished();
    }

And that's my layout:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent">
    <LinearLayout
            android:orientation="vertical"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:gravity="top"
            android:id="@+id/layout_ad"
            >
        <Button
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:text="Ad Sample"/>
    </LinearLayout>
    <org.andengine.opengl.view.RenderSurfaceView
            android:orientation="vertical"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:gravity="center"
            android:id="@+id/layout_render"
            />

</LinearLayout>

When I'm trying to debug, I can see that EngineOptions are creating, but no one of the LayoutGameActivity's methods was called (onCreateResources, onCreateScene or onPopulateScene). Can someone tell me what I've missed?

© Stack Overflow or respective owner

Related posts about android

Related posts about andengine