A speedier loop?
MattSoden
Member Posts: 30
I'm currently using the attached logic to run a loop that spawns 575 (23x25) elements behind a masking image that will be removed when the 'ready?' boolean is set to true - and the loop has finished.
It is taking approx 9 seconds for this loop to run to completion on my PC, and this feels too long. 3-4 seconds would feel better if that is possible.
Is there a way to speed up this looping - or will I just need to wait for the loop behaviour to come to PC with the next update?
https://www.dropbox.com/s/29s0lb3217pi165/Spawner_Rules.jpg?dl=0
Hope you can see the JPEG image as I didn't want to link it into this post as it's a bit tall!
I should also add that the spawned element has quite a few complex rules of it's own...
Comments
I would wait for the loop behavior. I believe there is a release candidate for Windows which contains the loop behavior. Having said this, it shouldn't be too long before you get your hands on the official release.
However, if you didn't want to wait that long you can continue to tweak your current setup.
My GameSalad Academy Courses! ◦ Check out my quality templates! ◦ Add me on Skype: braydon_sfx
Thanks @Braydon_SFX, I guess I'll have to wait for the 0.12 PC release.
Duplicate the actions within the timer.
Example - as you have it.
Rule While A is < 100
--Timer - every 0 seconds
----Spawn something at A
----Change A to A+1
Example - faster.
Rule While A is < 100
--Timer - every 0 seconds
----Spawn something at A
----Change A to A+1
----Spawn something at A
----Change A to A+1
----Spawn something at A
----Change A to A+1
----Spawn something at A
----Change A to A+1
----Spawn something at A
----Change A to A+1
----Spawn something at A
----Change A to A+1
----Spawn something at A
----Change A to A+1
----Spawn something at A
----Change A to A+1
Thanks @Socks I'll look into that and see what time I can shave off...
Don't think I'd have ever come to that solution as it seems counter-intuitive to me!
Yeah, agreed, it does seem a little counterintuitive, but the logic is sound. There are other ways to speed up spawning multiple actors, just did a quick test and was able to spawn 720 actors in just under 1.4 seconds, so if the multiple actions within a single timer cycle is still not fast enough there are other options.
OK, so duplicating the one spawn rule to twelve rules has cut the time to approx 1.7 secs - my flabber is officially gasted!
Several of us worked to improve the efficiency of looping a while ago, prior to the Loop behavior in Mac Creator. Timers were so slow even at every 0 seconds that we needed something better.
One of the best efforts, if not the best, was the Hyper Loop: http://forums.gamesalad.com/discussion/54922/hyperloops-loop-to-your-hearts-content. Also Fast For Loops: https://forums.gamesalad.com/discussion/55050/fast-for-loop-a-collection-from-the-community-merged-into-a-single-really-really-fast-loop.
I think both of those demos are Mac-based but it's possible to open Mac Creator files in Windows if you Google the method. I also believe @Socks described one of the methods already above so you may already be set.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Yep, like tatiang says there are a few super fast looping ideas out there, you can almost certainly get that 1.7 seconds down even more if you need to.