How do I spawn and destroy actors before and after the camera?
colander
Member Posts: 1,610
I have a vertically scrolling game with two scenes each 1440 high by 480 wide and each scene has about 180 actors on it. On older devices (iPhone 4 and iPad 1) it is a bit laggy/jittery at the start when iAds starts to run and when the ads change during play in ad hoc. Even with iAds off this behaviour can still be there at times.
I have been trying to find information on spawning and destroying actors before and after the camera which follows the main actor hoping this might improve performance. On iPhone 4 it takes about 6 to 7 seconds to change to a game scene so I assume it is laying out the whole scene before it starts. Can someone show me how to go about this or point me to information that will?
EDIT: All actors are background actors (Some have rules in them) and they don't move, only the main actor moves.
I have been trying to find information on spawning and destroying actors before and after the camera which follows the main actor hoping this might improve performance. On iPhone 4 it takes about 6 to 7 seconds to change to a game scene so I assume it is laying out the whole scene before it starts. Can someone show me how to go about this or point me to information that will?
EDIT: All actors are background actors (Some have rules in them) and they don't move, only the main actor moves.
Comments
That is the usual easy way. They just overlap or collide with the wall set outside the stage.
In regards to load times GameSalad can be slow loading stuff in to memory - check your memory usage in the preview tool - and also remember that these older devices are slow and stutter with Apples own OS at times.
One way to make scene load times shorter is to not preload artwork on things that you don't see instantly on stage.
But the caveat with that is when GameSalad loads a lot of stuff the frame rate drops considerably sometimes.
You could try that however - it's easy enough to do by unticking 'preload artwork' - or if you have a lot to do @deepblueapps make a tool that will do it to all your actors.
I have also found with older devices that sometimes they need all the the apps shutdown and a restart to free up RAM. See if it is smoother after that too.
Some ideas that might help going forward, cheers, M@
I also restart my devices regularly to improve performance. Destroying actors behind would i think help but the main problem is when the scene first starts while the iAd behaviour is loading up. So I was thinking if I could load actors/instances in front of the camera as required instead of the whole scene at the start it might help performance. Is this possible?
Universal Binary Template - Universal Binary Template Instructions Rev 4 (Short) - Custom Score Display Template
Universal Binary Template - Universal Binary Template Instructions Rev 4 (Short) - Custom Score Display Template
Universal Binary Template - Universal Binary Template Instructions Rev 4 (Short) - Custom Score Display Template
So when your hero reaches a Y value you can spawn certain actors so they are appearing as the hero moves.
It is also hard to say without seeing it - and knowing how many similar actors there are the best way to do that - nor can we see the gameplay - the mechanic - so it's a bit tricky.
But if you look at endless running game templates they do that sort of thing. Do you know what I mean?