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 :
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