Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How can i stop pygame.time.set_timer?

I want to print the message 3 times. After then how can i stop pygame.time.set_timer in this example?

import pygame
 
pygame.init()
 
print_message = pygame.USEREVENT + 0

pygame.time.set_timer(print_message, 1000)

while True:
    for event in pygame.event.get():
        if event.type == print_message: 
            print("stop now ")`
  

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

this might not be the best solution but you can set the variable "print_message" to some thing else when you want it to stop

like this:

import pygame
 
pygame.init()
 
print_message = pygame.USEREVENT + 0

pygame.time.set_timer(print_message, 1000)

while True:
    for event in pygame.event.get():
        if event.type == print_message: 
            print("stop now ")
            print_message = 0
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading