How to solve the lag issue? Any tips/ tricks?
Hi all,
I am having serious problem with lags. I have an actor who will jump on some other actor. There will be obstacle, coins, etc spawned during the game one after another. These obstacle and coins are keep on moving using constraint attributes, and they have some timer behaviour, interpolate too inside. I use timer for the spawning frequency.
However, there is a very noticeable lag when the actor jump and when there are other actors spawned at the same time. The initial game will have the worst lag. Subsequently not so bad but there is still lag which is awful.
I cant use the recycle method because it will be tedious due to the number of the actors cannot be really predicted.
I tried the false spawn method but it doesn't help.
I tried to use change timer with my own time attribute but I have some unwanted issue with this method.
I have also tried preload art.
I experience the lag in Creator preview and in Android Viewer.
Could anybody advise what is the best way to solve this kind of lag?
What could be the issue? Is this common?
Any tips/ tricks for this kind of lags?
Please advise. Thank you.
Comments
How big is your project? Usually a lot of big images or audio could make the FPS decrease. Also inefficient coding could cause that lag
I used this method consolidate some of my timers and that seemed to help a lot, mostly I have used the every second one. I also moved some of my timers into other actors/events that were triggered at different times. That made it so there was not a ton of timers trying to track each other at the same time.
http://forums.gamesalad.com/discussion/44707/timers-are-for-chumps-gs-optimization-tips/p1
Thanks for the responses guys.
My project size is 6 MB. During the game play, at maximum there will be around 15 main actors sharing around 8 images. All the images is about 128x128 pixel or 128 x 256 pixel. No animation except using interpolate and particles which is unlikely the cause because particles will be spawned only when the actor collides or destroyed.
Could you please ellaborate further what kind of coding is considered as inefficient coding?
I have rules inside rules (nested rules).
example:
Rule: when A
nested rule: when B
nested rule: when C
I also have rules with many conditions and some other rules with similar condition.
Example:
Rule: When A and B and C and D
Rule: When A and B and E and F
Rule: When C and D and G and H
I have some timers with timers inside.
Example:
Timer: Every 5 second
Nested timer: After 3 second
I also try to put coding related to game play rules inside a main actor (hidden) which is spawned once in the beginning of game play and destroyed when the game is over.
In the character actors, i only put the coding related to the character's movement, size position, interpolate, collide and destroy rules
And the movement is using several constraint attributes.
Any of my coding style above considered as inefficient?
Thanks for the advice.
The timers are the cause of most lag. Show text can cause lag as well if 10 actors are displaying them at the same time.
My game use to lag when I had timers, I removed all the timers and it turns smoothly now. Replacing them with the Mod1 method and self.time> method is the way to go as they are lag free.