Stuttering Problem but 60fps

The game I am working on right now has a weird problem, stuttering even with a solid 60fps.
The easiest way to describe my game is the classic flash game Helicopter where the player is just an object on the left side and presses to move up and down while avoiding object moving across the screen.
I am not using any spawning in my project. All objects that can be collided with (10 total), are already off camera when the scene first loads. I have a timer in a separate actor that randomly picks an object and then sets it in motion across the screen.
When loading the game on my device, the viewer shows a solid 60fps.
My memory usage is:
Images: 5.3MB
Sounds: 0 (haven't added any yet)
Game Engine: 6.1MB
Other: 6.6MB
Total: 18.0MB
As pieces scroll across the screen, they appear to all, at the same time, jump back maybe 10-20 pixels, and then jump forward to where they should be and conintue on as normal.
I've tried using interpolate on all my objects instead of Move, I've tried using the Timer behavior as well as Self.Time, and I've even deleted a fair amount of objects on the scene. Even with 1 object, it will still stutter as though it is lagging yet, the fps would say otherwise.
I for the life of me can't figure out or explain this rubber band effect I'm having.
Any ideas?
The easiest way to describe my game is the classic flash game Helicopter where the player is just an object on the left side and presses to move up and down while avoiding object moving across the screen.
I am not using any spawning in my project. All objects that can be collided with (10 total), are already off camera when the scene first loads. I have a timer in a separate actor that randomly picks an object and then sets it in motion across the screen.
When loading the game on my device, the viewer shows a solid 60fps.
My memory usage is:
Images: 5.3MB
Sounds: 0 (haven't added any yet)
Game Engine: 6.1MB
Other: 6.6MB
Total: 18.0MB
As pieces scroll across the screen, they appear to all, at the same time, jump back maybe 10-20 pixels, and then jump forward to where they should be and conintue on as normal.
I've tried using interpolate on all my objects instead of Move, I've tried using the Timer behavior as well as Self.Time, and I've even deleted a fair amount of objects on the scene. Even with 1 object, it will still stutter as though it is lagging yet, the fps would say otherwise.
I for the life of me can't figure out or explain this rubber band effect I'm having.
Any ideas?
Comments
The objects and surroundings move right to left to give the appearance the player is moving.
I noticed if I comment out the behavior to increase score which is:
Timer - Every 1 second
Change Attribute Score = Score + 10
The stutter is almost non exsistant.
I've tried using a Self.Time to do score but that doesn't reduce stuttering.
Something seems to be going on with either the way the score is increasing or with the use of custom fonts to display the score.
good luck
kipper
I have 9 digits total on my screen. 7 for score to count up to the millions and 2 for a multiplier counter up to 99.
The only thing I can think of is that since my score is increasing so much (every 1 second), and not just when you collect something or touch something, those 7 constrains on the numbers might be messing things up.
Edit: I just removed all the custom fonts to track my score and the stuttering persists.
I disabled the score entirely and still notice sporadic stuttering. The score or custom font might not be my problem after all. Although stuttering goes way down if I disable the score.
I deleted said actors and the game runs smoothly. The problem, these actors are the custom score actors and actors I use to do custom collision regions.
Well at least now that I know the problem I can work on fixing it.
I narrowed my stuttering in game down to the number of constraints in the scene and movable actors. For all my score keeping, I now use self.time to update and change the custom font for my score as opposed to having constrains in 9 or 10 digits on the screen.
I had an additional 15 actors or so that I was still using as Movable and another 7 or so that had constrains.
I went through, modified these actors to all be non-movable, and now use interpolate instead of move and got rid of the constrains.
My game now runs as smooth as butter in comparison to before.
I went from close to 20 movable actors, and another 15 actors that had constrains, down to only 1 actor (the player) that is movable and I now have no constrains left in my game.
Optimization is key! Learn new stuff everyday.
- Jeff
Even after optimizing as much as I could think of, I still get stuttering.
Here is a short clip I made to show it.
You can really see the stuttering at 6, 10, and 17 seconds.
While this was running on the simulator, just like my device, it shows running at a constant 60fps, but all the actors that I have interpolating from right to left all appear to have the jitters as they move along.
The only movable actor on the scene is the player, and the only constrains are the score digits at the bottom.
If I remove the score digits, I can reduce the stuttering a bit more but then I have no clue how I can do custom scores if I am not able to use constrains as in TSB's video.
Help Please!
- Jeff
Should be fixed now.