How to solve the long lag problem?

zellhuangzellhuang Member, PRO Posts: 79
edited June 2012 in Working with GS (Mac)
Hi guys, I've met a serious problem.It makes game dosen't respond for about 1 minutes when scene changes.If u know how to solve this problem,please help me out! Thanks in advance!

I create an actor which contains about 140 rules,each rule contains only one behavior.For example,"When Spawnactor(attribute) = 1, it spawns Actor1(actor) in front of layer at posionX,posionY".I'm developing a card-strategy game,this actor is used to spawn cards,that's why it has to contain 140 rules.Let's call this actor SpawnCardsActor.
The SpawnCardsActor should be spawned as soon as the scene changed.If it dosen't spawn the SpawnCardsActor, the loading time of scene change is about 15 seconds.While it spawns the SpawnCardsActor,the loading time of scene change will be more than 1 minutes.That a terrible long lag :(

I've tried several methods to solve this problem though,none of them worked.
First,I seperate all the 140 rules from the SpawnCardsActor into 7 actors. E.g. actor 1 contains 20 rules which spawn card1~20,actor 2 contains 20 rules which spawn card21~40,and so on.Then,I created a rule in the scene to spawn these 7 actors one by one but not in the same time.The lag is still there :(
Then I tried another method.I created another actor(let's call it ActorS) in which there is only one behavior that is spawn the SpawnCardsActor.I put ActorS in the scene, so when the scene starts,ActorS will run and spawn SpawnCardsActor.I hope this method would work.But still no luck XD

Can anybody know how to solve this problem.It has plagued me for about 2 weeks..

Best Answer

  • ammansabetammansabet Posts: 4
    Accepted Answer
    Your problem is that you have to re-load all the rules every time the card spawns.

    Instead, put ALL the rules in one actor that stays on the sage continuously, so GS doesn't have to re-load them all the time. Have that actor turn those rule sets on or off based on booleans assigned to each card. Trigger the appropriate set of rules to true or false if the card is in play or if it isn't. That should cut down on the load lag.

Answers

  • zellhuangzellhuang Member, PRO Posts: 79
    Hi there,

    140 rules is a lot of rules.
    When the scene loads it has to look through each rule before it can load.

    this post is in 2 parts. ...

    Thanks for your help,man! every time I got a problem,u r the first one come to help me,u r such a good guy :)
    Sorry my English sucks and didn't described the detail accurately,so u might misunderstand my problem.let me explain.

    1)The SpawnCardsActor contains 140 rules but not spawn all the 140 cards one time.Just like playing poker,every time draw a card,it will spawn the one we draw.There are 140 kinds of cards in my game.when playing my game,I may have 10 cards in hand at most.That means it may spawn 10 cards at most. We don't know which card we will draw,so, the 140 rules each is used to spawn 1 kind of card.

    2)I've tried to load the SpawnCardsActor after the scene loaded though,it didn't make any difference.I create a actor to spawn the SpawnCardsActor instead of putting the SpawnCardsActor directly in the scene before it loads.When the scene loads,it won't load the SpawnCardsActor but load the actor which will spawn the SpawnCardsActor.And then,this method looks making no difference:(

  • zellhuangzellhuang Member, PRO Posts: 79
    this problem is still plaguing me (:| can anybody else help me?
  • zellhuangzellhuang Member, PRO Posts: 79
    Your problem is that you have to re-load all the rules every time the card spawns.
    @ammansabet hi,friend,thanks for your help.I'v already solved the problem and I think your method is the best way :)
Sign In or Register to comment.