AndEngine Performance Tip of the day

  ... tutorials on how to use AndEngine.

AndEngine Performance Tip of the day

Postby Nicolas Gramlich » Sun Oct 17, 2010 10:12 pm

Hi,

to improve the performance of your AndEngine app a few % you can do the following:

Add a "theme.xml" to your res/values folder:
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <resources>
  3.     <style name="Theme.NoBackground" parent="android:Theme">
  4.         <item name="android:windowBackground">@null</item>
  5.     </style>
  6. </resources>
Parsed in 0.001 seconds, using GeSHi 1.0.8.4


and then in your AndroidManifest.xml add the Theme to your game-activity:
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <activity android:name=".MyGameActivity" android:theme="@style/Theme.NoBackground"/>
Parsed in 0.000 seconds, using GeSHi 1.0.8.4


Best Regards,
Nicolas
Nicolas Gramlich
Site Admin
 
Posts: 1734
Joined: Mon Jun 07, 2010 6:20 pm
Location: Schriesheim, Germany

Re: AndEngine Performance Tip of the day

Postby alex » Mon Oct 18, 2010 5:15 am

thanks for the tip, Nicolas,
does this affect:

Scene.setBackground(new ColorBackground(0.0f, 0.0f, 0.0f));

at all ?
alex
 
Posts: 275
Joined: Thu Jul 01, 2010 8:21 pm

Re: AndEngine Performance Tip of the day

Postby cschua » Mon Oct 18, 2010 10:14 am

is it possible to set or change the theme on run time?
Published: Another Strobe Light, Nitey Night Light, Live Wallpaper ASL, Score Keeper, etc.

Future: Happy Halloween Game (using AndEngine)
Castle Game (using AndEngine)
Another Live Wallpaper (using AndEngine)
Etc.
cschua
 
Posts: 48
Joined: Sat Sep 11, 2010 11:47 pm

Re: AndEngine Performance Tip of the day

Postby oldskool73 » Fri Nov 05, 2010 3:40 am

@alex - no, it just stop another background that you'll never see being drawn under the app.

@cschua - you can call :

getApplication().setTheme(R.style.MyTheme);

...but as far as I'm aware it doesn't take effect until the next application is loaded, so basically no.
oldskool73
 
Posts: 128
Joined: Tue Oct 12, 2010 4:04 pm

Re: AndEngine Performance Tip of the day

Postby BillyGalbreath » Mon Nov 29, 2010 6:23 am

Freakin' awesome! This tip helped boost my overall FPS from about 45 to about 60! Thanks a million! :D
BillyGalbreath
 
Posts: 7
Joined: Mon Nov 29, 2010 5:32 am

Re: AndEngine Performance Tip of the day

Postby JamesR » Fri Jul 27, 2012 1:56 am

I see in the AndroidManifest.xml:
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" >
Parsed in 0.000 seconds, using GeSHi 1.0.8.4


just before the activity line:

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.  <activity  android:name=".MainActivity" android:label="@string/title_activity_main" android.theme="@style/Theme.NoBackground" >
Parsed in 0.000 seconds, using GeSHi 1.0.8.4


For getting the most benefit from this optimization, should one remove the auto-generated setting of theme for the application, set the application's theme to NoBackground instead of the activity's, or just leave it as it is?

Thanks,
James
JamesR
 
Posts: 2
Joined: Thu Jul 26, 2012 11:35 pm

Re: AndEngine Performance Tip of the day

Postby ABoss » Tue Jul 31, 2012 3:26 pm

Instead of placing it in <activity ... /> I can also place this in <application ... />? And what would there be a difference between not stating an android:theme in the <application .../> or having <application android:theme="Theme.NoBackground" ... />? Thanks.
ABoss
 
Posts: 2
Joined: Thu Jul 26, 2012 3:10 pm


Return to Tutorials

Who is online

Users browsing this forum: No registered users and 12 guests