0
我的主要遊戲活動課得到錯誤:試圖增加OpenGL的在我的項目,但我的setContentView()
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
public class SFGame extends Activity{
SFGameView gameview;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
gameview= new SFGameView(this);
Log.d("ashwin", "wrong");
setContentView(gameview);
}
}
我SFGameView類代碼:
import android.content.Context;
import android.opengl.GLSurfaceView;
public class SFGameView extends GLSurfaceView{
public SFGameView(Context context) {
super(context);
// TODO Auto-generated constructor stub
}
}
我發現,錯誤的是當我嘗試從SFGameView
級別呼叫setContentView(gameview)
時發生。
是否有必要將此class SFGameView extends GLSUrfaceView
也添加到清單中,如服務?如果是,那麼如何?
爲GLSurfaceView清單
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.ku.starfighter.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="Sfmainmenu"
android:screenOrientation="portrait"></activity>
<activity android:name="SFGame"
android:screenOrientation="portrait"></activity>
<service android:name="SFMusic"></service>
</application>
三江源先生添加任何東西... BT我沒有得到你。請你詳細說明一下。 我應該在哪裏設置下面的代碼...在SFGameView類? 我確實設置了,但什麼是渲染器。 GLSurfaceView.setRenderer(renderer); – AkshayKriti
「Renderer」接口的實現類用作將執行所有繪製到「GLSurfaceView」的類。它有3個回調函數'onDrawFrame(GL10 gl)','onSurfaceChanged(GL10 gl,int width,int height)'和'onSurfaceCreated(GL10 gl,EGLConfig config)'。 GL10對象允許您發佈GL10命令/函數並將其應用於GLSurfaceView。 – nagloan