【发布时间】:2011-11-23 03:03:27
【问题描述】:
我的问题是我们的游戏可以立即切换到菜单和设置模式,但是加载纹理需要 4-6 秒,初始化 GL 渲染模式最终我只是使用 6 个简单的纹理在游戏中创建了 6 个精灵。
请帮我回答两个问题: 1.如何在android os中预加载我们的资源以更快地启动我们的游戏? 2.为了使用一个技巧来创建activity之间的实例切换,我怎样才能保持我的activity与GLSurfaceView状态?
我为了帮助你了解我的情况,请阅读以下代码:
游戏使用 3 个活动,您可以在以下配置中看到:
<application android:label="@string/app_name"
android:icon="@drawable/icon" android:allowBackup="true">
<activity android:name=".Menu" android:screenOrientation="portrait"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:launchMode="singleTop">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".ReTouch" android:screenOrientation="portrait" />
<activity android:name=".Preference" android:screenOrientation="portrait" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" />
</application>
我的 .ReTouch 类是从 RokonActivity 扩展的类(我的游戏使用 rokon 引擎),该引擎将创建一个 GLSurefaceView 以在 OpenGL ES 中渲染我的游戏 您可以在这里获取 RokonAcitivity 的源代码:http://code.google.com/p/rokon/source/browse/tags/release/1.1.1/src/com/stickycoding/Rokon/RokonActivity.java
public class ReTouch extends RokonActivity {
public static final int REPLAY_DELAY_INTERVAL = 1000;
private ReTouchGameBoard reTouchGame;
和.Menu、.Preference是android应用程序中两个正常的标准活动。
我正在使用这种方法来启动和切换活动:
playButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
soundPool.play(soundId, 1, 1, 1, 0, 1);
startActivity(new Intent(Menu.this, ReTouch.class));
}
});
settingButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
soundPool.play(soundId, 1, 1, 1, 0, 1);
startActivity(new Intent(Menu.this, Preference.class));
}
});
quitButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
soundPool.play(soundId, 1, 1, 1, 0, 1);
finish();
}
});
【问题讨论】:
标签: android glsurfaceview