I just need general advice for making my game lag less, here’s the link. What could be better specific to my program?
Game seems to run at an acceptable speed for me
I think your concept of having a load of forever loops showing or hiding sprites would be the thing I’d address if its running too slow for you
You seem to have lots of when <> blocks. These check the condition EVERY FRAME, instead of when green flag clicked or other hat blocks (they just get triggered whenever that happens). Maybe try putting some of those into when green flag clicked forever wait until blocks. Can’t explain it well, so here’s a example.
In the title sprite, you can replace this
with this:
Or you could change stage switching to a message, call it “stage change”, and use the data property:
Call it like this:
![]()
You also use a lot of touching color blocks, which can be slow. You could replace them with some sort of bounding box calculation (however that is way too much out of my scope for right now (its 9:53! I’m in school!)
This will have no effect on performance - the wait until block checks EVERY FRAME as well.
This will help a lot though!
(I know this topic is already marked as complete, but there’s still so much room to drastically improve the performance that I noticed.)
Looking through your project, there’s really one thing I notice over and over that I am almost certain is the reason for the lag. And this is separation; in other words, there are so many things, whether they are scripts, or even entire sprites, that are separated that really don’t need to be. You have dozens of separate scripts that all run when the green flag is clicked, and this just isn’t necessary. However, the way to fix this, fortunately, is incredibly simple; just combine some of your scripts.
Also, you use the “when touching color” block, which, at least in my experience, is the most useless, and laggiest piece of garbage in all of Snap. Use the normal “touching” block, instead; it’s much faster, and not much different.
Would you like me to go through the project and show some of the optimization, so that you can understand what I mean?
And, I noticed a bug on the screen; if you try to exit, you go to the next screen, and then are immediately sent back, because when the next screen is loaded, you are placed on the left side of the screen, and are far enough to make the game send you to the previous screen, effectively doing nothing, and preventing you from leaving.
That’s interesting that hasn’t happened to me yet. Is it on every stage?
How would you use the regular touching block with all the different green sprites so that it would work with all of them?
Just check all of them. Yes, the touching color block is so slow that it is faster to check all of the sprites than it is to use it.
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.



