Forum Archive

Pausing inside classes with "Scene" object

happy_variable

How do you pause the class with object "Scene" or "SpriteNode" for a certain amount of time, while leaving other classes to work?

I am not sure that time.sleep() does the job.

Thanks for your answers, programmers!

chriswilson

Hi @happy_variable

What exactly do you want to achieve. There are several methods that might help.

If it is primarily animations etc, then SpriteNode.run_action() will allow you to apply actions to nodes. There is an Action.wait() method which might be what you are looking for. Action.sequence() and Action.group allow you to run multiple actions sequentially or together.

Action.call() can call any function as part of an animation. It can thus be set up to function like a timer or delay.

Another option would be ui.delay() which calls a function after a particular delay.

time.sleep() functions might need to be decorated with @ui.in_background to work as expected. This can sometimes cause problems if several processes are running in the background as well.

I hope this helps a little. Let me know exactly what you need to do and I could make specific suggestions.

happy_variable

Thanks, @chriswilson!

I have noticed about the Action.wait() method before you answered (but later than posting this question), but still thanks for your support. I already got all the information I wanted and expected, so I don't need concrete suggestions on concrete topics.

I'm going to post a new question soon, and I'll be happy to get supported by you on it, again Thanks!