Make 2d Game with many sprites in scene help?

Tutorials concerning the OpenGL® ES cross-platform API for full-function 2D and 3D graphics on the Google-Android platform.

Make 2d Game with many sprites in scene help?

Postby chelendez » Mon Mar 02, 2009 6:14 pm

Hi, i 'm making a 2d game , is a vertical ship shooter. My problem is that when the emulator is using GC Freed , the game slows by 1 millisecond (lag), this happens only when using GC Freed. I'm use the method draw(Canvas c).

Somebody a idea? plz.
chelendez
Freshman
Freshman
 
Posts: 4
Joined: Fri Feb 27, 2009 9:51 pm

Top

Postby MrSnowflake » Mon Mar 02, 2009 7:03 pm

Try calling the gc yourself, so you can time when you want to gc.
User avatar
MrSnowflake
Moderator
Moderator
 
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Postby chelendez » Mon Mar 02, 2009 10:01 pm

when java call to Garbage collector my game slows (lag). If i will call System.gc() , is more slow. the games lunarGame and Snake no used many sprites. My game have many sprites. other idea.
chelendez
Freshman
Freshman
 
Posts: 4
Joined: Fri Feb 27, 2009 9:51 pm

Postby MrSnowflake » Mon Mar 02, 2009 10:42 pm

Ok, then why does it have so much gc to do? Is it all in your code? Then maybe you have too much variables and objects which get create every frame, so try to move every object create out of for loops when possible a,d reuse objects and thus avoid creating objects. Or (in an extreme case) have a more global approach and move such variables which you need every frame to a separate class or as field and use them, instead of recreating them every frame.

Also, in the docs there's a section about performance.

BTW, only 1ms can't be that big a deal can it? And if it is, maybe you are asking too much from the hardware.
User avatar
MrSnowflake
Moderator
Moderator
 
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Postby chelendez » Wed Mar 04, 2009 8:29 pm

thanks, i created many objects of type bounds by update ,now I only use vars type int.
chelendez
Freshman
Freshman
 
Posts: 4
Joined: Fri Feb 27, 2009 9:51 pm

Top

Return to Android 2D/3D Graphics - OpenGL Tutorials

Who is online

Users browsing this forum: No registered users and 11 guests