Will the game start to lag if the actors spawned don't get destroyed after off-screen?

winged_boxwinged_box Member Posts: 52
edited April 2014 in Working with GS (Mac)

The game will keep spawning new enemy, if I don't destroyed the spawned actor after it got off-screen will it lag the game after a long time?

Comments

  • CodeMonsterCodeMonster ACT, AustraliaMember Posts: 1,078

    Yes It most defently will happen.

  • winged_boxwinged_box Member Posts: 52
    edited April 2014

    @CodeMonster said:
    Yes It most defently will happen.

    My problem now is every time the actor got destroyed after off-screen my spawner won't spawn any more new enemies, this happened when i use timer with the After setting.

    If I select 'Every' the game will continue to spawn it even after it got destroyed but even though I set the time to random(1,5) it will always spawn at the same interval not random.

    Any advise for this?

  • SocksSocks London, UK.Member Posts: 12,822

    @winged_box said:
    The game will keep spawning new enemy, if I don't destroyed the spawned actor after it got off-screen will it lag the game after a long time?

    That depends on the particular circumstances, actors are automatically killed once they stray more than 500 pixels away from the edge of the scene ('scene' not screen).

  • SocksSocks London, UK.Member Posts: 12,822
    edited April 2014

    @winged_box said:
    My problem now is every time the actor got destroyed after off-screen my spawner won't spawn any more new enemies.

    It sounds like you have your code set up incorrectly. We'd need to see that code to be able to diagnose the issue.

  • HopscotchHopscotch Member, PRO Posts: 2,782

    @winged_box said:
    If I select 'Every' the game will continue to spawn it even after it got destroyed but even though I set the time to random(1,5) it will always spawn at the same interval not random.

    If you set an "every" timer to random(1,5) then it will get the random number only once at the start and then stick to that timing.

    In your case what you could do is the following

    change attribute self.lasttime = game.time
    change attribute self.delay = random(1,5)
    
    timer every 1 seconds run to completion
    
             rule if self.delay < game.time-self.lasttime
    
                      spawn something
                      change attribute self.delay = random(1,5)
                      change attribute self.lasttime = game.time
    
             end of rule
    
    end of timer
    
  • winged_boxwinged_box Member Posts: 52

    "change attribute self.lasttime = game.time

    < game.time-self.lasttime"

    Wouldn't this make it equal to '0'?

    "self.delay < game.time-self.lasttime

    spawn something
    change attribute self.delay = random(1,5)"

    My self.delay will be (1,5) meaning it will never be <game.time-self.lastime.

    How will this work?

  • winged_boxwinged_box Member Posts: 52

    Tried that method but it won't spawn any enemy.

Sign In or Register to comment.