Cameron, Are you using time-based movement or frame-based? Would you mind sending me an APK? I can check it out for you and maybe help out a little with some suggestions.
On Jul 22, 3:16 pm, Cameron <cameron.m.john...@gmail.com> wrote: > Thanks for the reply Matt, > > I have used the DDMS in Eclipse to see if there is any GC that happens > and nothing that belongs to my thread. There are some but those are by > the Android system itself. > > I have also optimized the hell out of this game following all of the > examples from google and other forums. > > I do exaclty what you said with the adding new monsters example on the > go but it doesn't seem to great any GC events. I will preload them > like you suggested and see what happens. > > Also I will try to use the uptimeMillis(). Right now im using "now = > System.currentTimeMillis();" > > On Jul 22, 1:07 pm, Matt <matthew.quig...@gmail.com> wrote: > > > > > Well, it sounds like the frame rate goes down intermittently because > > of the garbage collector. > > > First of all, you should not be doing any object creation during your > > game loop. This way there is never any need for a GC. > > 1. Create all of your objects before hand. For example, > > Monster[] mMonsters = new Monster[Monster.MAX]; > > setup() { > > for (int i = 0; i < mMonsters.length; i++) { > > mMonsters[i] = new Monster(); > > mMonsters[i].used = false; > > } > > ...} > > > Instead of creating a new monster every time one comes into play, just > > set its used flag to true (and set it to false, instead of deleting > > it, when the monster is done). > > > 2. Use android.os.SystemClock.uptimeMillis() when limiting your FPS. > > Basically what you want to do is keep track of each game tick, and if > > it hasn't been 1/30 seconds yet, sleep for the remaining time. > > > 3. Google "java game optimization". > > > -Matt > > > On Jul 22, 3:46 pm, Cameron <cameron.m.john...@gmail.com> wrote: > > > > I based my game off of the lunar lander demo, although heavily > > > modified, and I can get around 40-50fps but the problem is it > > > fluctuates between 40-50fps so much that it causes the moving graphics > > > to jitter! Its very annoying and makes my game look really shitty when > > > in fact its running at a good frame rate. > > > > I tried setting the thread priority higher but that just made it > > > worse... now it will fluctuate between 40-60fps... > > > > I was thinking of limiting the FPS to about 30 so that it will be > > > constant. Is this a good idea and does anyone else have experience or > > > a different solution? > > > > Thanks! > > > > PS: If you have an example of limiting or creating constant FPS that > > > would be helpful. I've tried it before but never got it quite right. -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en