Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to retain the state of a activity that has a GLSurfaceView
    primarykey
    data
    text
    <p>My problem is our game can switch into menu and setting mode instantly but it will need 4-6 seconds to load texture, init GL render mode eventually I just used 6 simple textures to create 6 sprites in game.</p> <p>Please help me answer two questions: 1. How can I preload our assets in android os to start our game quicker? 2. In order to use a trick to create instance switch between activity, how can I retain my activity with GLSurfaceView state? </p> <p>I order to help you understanding my situation, please read the following code:</p> <p>The game using 3 activities as you can see in following configuration:</p> <pre><code> &lt;application android:label="@string/app_name" android:icon="@drawable/icon" android:allowBackup="true"&gt; &lt;activity android:name=".Menu" android:screenOrientation="portrait" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:launchMode="singleTop"&gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN" /&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;activity android:name=".ReTouch" android:screenOrientation="portrait" /&gt; &lt;activity android:name=".Preference" android:screenOrientation="portrait" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" /&gt; &lt;/application&gt; </code></pre> <p>My .ReTouch class is a class that extended from RokonActivity (I am using rokon engine for my game), this engine will create a GLSurefaceView to render my game in OpenGL ES You can get RokonAcitivity's source code here: <a href="http://code.google.com/p/rokon/source/browse/tags/release/1.1.1/src/com/stickycoding/Rokon/RokonActivity.java" rel="nofollow noreferrer">http://code.google.com/p/rokon/source/browse/tags/release/1.1.1/src/com/stickycoding/Rokon/RokonActivity.java</a></p> <pre><code> public class ReTouch extends RokonActivity { public static final int REPLAY_DELAY_INTERVAL = 1000; private ReTouchGameBoard reTouchGame; </code></pre> <p>and .Menu, .Preference are two normal standard activity in an android application.</p> <p>I am using this method to start and switch between activities:</p> <pre><code> 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(); } }); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload