How do I spawn and destroy actors before and after the camera?

colandercolander Member Posts: 1,610
edited November 2013 in Working with GS (Mac)
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.

Comments

  • mataruamatarua Auckland, New ZealandMember Posts: 854
    Could you not put some walls in that when the actors hit they get destroyed?

    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@
  • colandercolander Member Posts: 1,610
    @matarua I tried unchecking preload artwork it didn't help and made the game stick for a split second when it collided with the moving actor. Most of the art is light weight cartoon art. I left one actor unchecked which displays achievements and has 76 different pieces of art, is about 6mb and a bunch of rules and is not required very often. I also compressed all art with ImageOptim.

    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?
  • mataruamatarua Auckland, New ZealandMember Posts: 854
    @colander - the process is termed 'lazy loading' - that's taking the chunk of data that gets loaded at the start and breaking it up and only loading things when they are needed.
  • colandercolander Member Posts: 1,610
    edited November 2013
    @matarua I just read your post in thread http://forums.gamesalad.com/discussion/comment/425026#Comment_425026 about lazy loading. It doesn't sound like it is worth trying to do. Hopefully the coming GS improvements (lol….sorry GS couldn't help the laugh :).) will help.
  • mataruamatarua Auckland, New ZealandMember Posts: 854
    All good :) hehe
  • mataruamatarua Auckland, New ZealandMember Posts: 854
    @colander remember my lazy loading was with a memory intensive animation. So don't be scared to use it. It could be the answer for you.
  • colandercolander Member Posts: 1,610
    @matarua How do I go about this, I mean how do I stop the actors from loading and then get them to load as needed?
  • mataruamatarua Auckland, New ZealandMember Posts: 854
    They can not be on stage if you want them to affect that initial loading time.

    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?
Sign In or Register to comment.