Best way to spawn

BreezeonholdBreezeonhold Member Posts: 187
edited November -1 in Working with GS (Mac)
My game runs super slow on my ipod touch and was wondering if I could some how make it faster by changing the way my spawners work.

I have cars spawning out however is there a better way to do that? Should I even be using the spawn feautre??

Comments

  • scorelessmusicscorelessmusic Member Posts: 565
    I know that there are many who would try to avoid spawning if possible. It just takes some juggling with bringing a pre-determined number of actors on and off stage.

    While testing for a tutorial project, I tested spawning by making something spawn everytime I tapped the screen and I had a counter to track how many actors were spawned this way. The frame rate seemed to drop by about half when I had spawned about 300-400 actors which are all still live on the stage.
  • specialist_3specialist_3 Member Posts: 121
    Spawning uses up memory and can lower FPS.

    Either

    1) You create multiple instances of your actor and put them offscreen and move them in/out when needed based on a set of rules OR

    2) Prespawn them (finite number) at run time (just before game starts). Meaning when game scene is loading, you spawn a dozen and keep them offscreen. Then as when u want, you move them in and out of the play area.
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    it also depends on how "heavy" the actors are with rules. I found that having 30 moving actors that use VectorToAngle to chase my main actor was about the limit for iPad. There were other things going on as well, but at around 40 the lag became noticeable and unacceptable to me so I limited it to 30 at a time.

    The best way to avoid spawning is to recycle your actors (look in code monkeys tips at the top of the forums).
  • BreezeonholdBreezeonhold Member Posts: 187
    Ok so for some reason right when my actor jumps it goes from 55 fps to 1 fps for maybe .5 seconds at most then goes straight back up.

    How can I fix that??? Is it because my acceleration is to high on the jump..

    My jump is... accelerate speed: 8500 for .1 seconds.
  • ORBZORBZ Member Posts: 1,304
    I use spawn, but i don't use it inside tight loops. But for example... i DO use it to spawn bullets believe it or not. It works fine because bullets are dumb and simple. I wouldn't use it to spawn 20 enemies. But I would use it to spawn one or two.
Sign In or Register to comment.