Change OnScreenImage every second

hello.
i am a beginner in panda…and i reeally need help, please!
i am doing a game and i want to display a timer that shows how much time the user has to win, otherwise he will lose.

i am trying to display this timer with onScreenImage (numbers from 10 to 1), but i dont know how to change each image (from 10 to 9, 9 to 8, etc) every second.
i tried sequences , but i cant find anything related to onScreenImage…

anyone knows how to do this? or another way to display a cool timer?

Try with a task:

def updateClock(self, task):
    self.clockLabel['text'] = self.getTimeRemaining()
    return task.again

taskMgr.doMethodLater(1, self.updateClock, 'updateClock')

You could also use a Sequence if you wrap your update function call in a Func() wrapper.

David

hello.
thanks for answering but i didn’t understand what that method does. :frowning:
how am i suppose to change the images? where am i going to add that method that changes the images and how am im going to use the updateClock ??

im sorry! but i am really a beginner…

Hmm, well, I was showing you how to use tasks to perform an operation once per second. If you need a more fundamental introduction to Panda, such as how to update an image or how to load a model and find the textures within it, you might need to spend some time going through the examples and the first few pages of the manual, at least. Tasks, images, and models are all topics covered in the examples and in the manual. :slight_smile:

When you have read all this and played with various techniques, it might be clearer how to proceed. If you still have questions, feel free to ask again.

David