0

たとえばCCGLSurfaceView、他のAndroidネイティブビューと組み合わせて動作させるという問題に悩まされています。ImageView私はCocos2Dを使用してゲームの開発を開始しましたが、後でadmobを介して広告を追加する予定です。CCGLSurfaceViewしたがって、 (私のゲームのOpenGlビュー)を上部で実行したいので、その下に広告が表示されます。

両方のビューを手動で(XML経由ではなく)相対レイアウトに追加するなど、すでにいくつかのことを試しましたが、取得を続けるnull pointersとアプリが強制終了します。

また、に統合する方法を説明するこのチュートリアルも試しadmobましたOpenGl SurfaceView。しかし、それでも機能しませんでした。おそらく、Cocos2dを使用しているためですか?

わかりません、誰かがこの(おそらくcocos2d固有の)問題で私を助けることができますか?

4

1 に答える 1

1

私たちはあなたのコードを必要としています(あなたがあなた自身に基づいているものへのリンクを置くことは全体的にあまり役に立ちません)

私のアプローチは、これらすべてをレイアウトで定義することです

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:gravity="center"
        android:orientation="vertical" 
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">

        <LinearLayout 
            android:gravity="center_horizontal"
            android:orientation="horizontal"
            android:layout_alignParentTop="true"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content">

        </LinearLayout>

        <android.pixelrain.opengl.GLSurfaceViewChipmunk android:id="@+id/composed"
            android:gravity="center"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
        />

        <LinearLayout
            android:id="@+id/linearLayoutAd"
            android:layout_height="wrap_content"
            android:layout_width="fill_parent"
            android:layout_alignParentBottom="true"
            android:orientation="vertical"
            android:gravity="center_horizontal"
        />

</RelativeLayout>

GLSurfaceViewChipmunkは、cocos2dに置き換えるものであることに注意してください。

そしてアプリケーションで

 private void InitAdView()
    {
        LinearLayout layout = (LinearLayout)findViewById(R.id.linearLayoutAd);

        // Create the adView
        adView = new AdView(this, AdSize.BANNER, AppSettings.AdmobAppId);

        ...set your add listener

        // Add the adView to the layout
        layout.addView(adView);
于 2011-06-24T10:14:35.253 に答える