Count down


How can I make a countdown? Is there any examples available?
Thank you


Here it’s an example:

var timer = 10; // for a 10 sec timer

parent.on("pointerdown", (e) => {Z.every(1000,myTimer); }); // call myTimer() every sec

function myTimer(){
    symbol.nodes.textField.text("timer: "+timer); // display the countdown in a text node
    if(timer--<=0)Z.everyOff(myTimer);  // cancel the call if timer <= 0 

Hope it can help. :slight_smile:


Thank you jvouillon. That is what I am looking for. :wink:
What assets do I need to to have in place so I can add this code? Just a text image with nothing in it?
Thanks again.


You need just 2 things:

  • a plan (or an image) to set the script on the pointerDown() event
  • a text object to display the timer

Here it’s the zpp example: test.zpp (72.9 KB)

Timer functions

Wonderful. I thought it would be much more difficult. Thank you so much!