Home / Topic / CREATING A DIGITAL TIMER CLOCK THAT COUNTS DOWN FROM 2 MINUTES

CREATING A DIGITAL TIMER CLOCK THAT COUNTS DOWN FROM 2 MINUTES

Home Kwiksher Forums Help me! CREATING A DIGITAL TIMER CLOCK THAT COUNTS DOWN FROM 2 MINUTES

Tagged: , ,

Viewing 2 posts - 1 through 2 (of 2 total)
  • #84048

    I am having a hard time finding tutorials on creating a digital timer clock that counts down from two minutes.
    I can do a countdown from 120 seconds but I was hoping to do a countdown with a clock that looks like this “2:00”
    and counts down to “0:00” Does anyone have a recommended tutorial? The clock tutorial and the physics game with timer tutorial did not really help with this.

    I found some external code on Github for a stopwatch and Glitch Games timer but then I always run into the problem of incorporating it with my Kwik project and variables. Any help would be greatly appreciated!

    Thank you!!
    Christi

    Yamamoto
    Keymaster
    #84072

    hourText, minuteText and secText are photoshop layers and they are replaced with Text Replacement of Kwik.
    Then the following external code changes the text from 02:00 to 00:00 . You may add your own action of Kwik, if levelTime == 0.

          local levelTime = 120
           local function updateTime()
              levelTime = levelTime -1
              local time = os.date("!*t", levelTime )
    
              local hourText = time.hour
              if (hourText < 10) then hourText = "0" .. hourText end
              layer.hourText.text = hourText
    
              local minuteText = time.min
              if (minuteText < 10) then minuteText = "0" .. minuteText end
              layer.minuteText.text = minuteText
    
              local secondText = time.sec
              if (secondText < 10) then secondText = "0" .. secondText end
              layer.secText.text = secondText
    
              if levelTime == 0 then
                layer.hourText.text= ""
                layer.minuteText.text = ""
                layer.secText.text = ""
              end
          end
    
          -- Update the clock once per second
          local clockTimer = timer.performWithDelay( 1000, updateTime, levelTime )
    
Viewing 2 posts - 1 through 2 (of 2 total)

The forum ‘Help me!’ is closed to new topics and replies.