Hi! I've been having trouble with having loops work correctly. I want to show a sprite moving on a loop, and stop it when I want with a trigger, but it almost always just crashes it? How do I get a loop to run in the background like that, and then let other things happen until I want to take it off? I'm trying to do it in the script editor, and I know how to code.
Looping Problem
Learning Ruby and RGSSxThe engine uses 'Scenes' to manage everything, so the typical flow looks like this:
Every frame the 'main' function of the Scene Class is called.
This function usually has a reference to a Spriteset Class.
The Spriteset Class manages all the sprites.
This leads to the following pseudo-code
In function main, call @spriteset.update
In function spriteset_update, call sprite.update for all sprites
In function sprite_update, run your code for moving it
Every frame the 'main' function of the Scene Class is called.
This function usually has a reference to a Spriteset Class.
The Spriteset Class manages all the sprites.
This leads to the following pseudo-code
In function main, call @spriteset.update
In function spriteset_update, call sprite.update for all sprites
In function sprite_update, run your code for moving it
A section of your code and the actual error message would be really helpful. We have no way of knowing what you're doing wrong otherwise. You didn't even say what class you're putting your code into.
You should not do loops to update graphics within the menus. They already have a repeated update loop. Set up your variables in the initialization or refresh method, then update them and update the sprite in the update method. Depending on where you call walking_actor_graphic from, you could be going into an endless loop, as your code is calling the update method and it shouldn't be, because that's already being called once per frame.
Okay, thanks for the help!
Original thread: https://forums.rpgmakerweb.com/threads/looping-problem.68162/

