以前はアプリに SimpleBaseGameActivity を使用していましたが、すべて問題ありませんでしたが、アプリに広告を追加したいので、LayoutGameActivity を使用しようとしました。しかし、レンダー ビューが完全に黒くなり、その理由がわかりません。それが私のコードです:
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();
}
そして、それが私のレイアウトです:
<?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>
デバッグしようとすると、EngineOptions が作成されていることがわかりますが、LayoutGameActivity のメソッドはどれも呼び出されませんでした ( onCreateResources
、onCreateScene
またはonPopulateScene
)。誰かが私が見逃したことを教えてもらえますか?
UPD: xmlでボタンを下に移動すると、シーンが表示されることがわかりました:
<?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">
<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
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>
</LinearLayout>
しかし、今はボタンが見えず、まだ SimpleBaseGameActivity を使用しているようです。