Skip to content

This is a custom timer node that can do both countdowns and coups.

License

Notifications You must be signed in to change notification settings

BigDC/CounterTimer

Repository files navigation

This custom CounterTimer node can do both countdowns and countups

  1. Create a Scene or have one already.

  2. In your Scene, add a Label node.

  3. Add the custom CounterTimer node to your Scene.

  4. In the CounterTimer node's Inspector properties, set the following 2 properties.

        Counter Type to either "countdown" or "countup", without the "".'.
        ex.     Counter Type countdown
        Counter Type determines the type of counter the CounterTimer node is. Either a countdown timer or a countup timer.
    
        Time Value to a value in minutes
        ex. Time Value 5
        Time Value is the total number of minutes to either countdown from or countup to, depending on which Counter Type you've chosen.
    
        See the CounterTimer demo settings to help you
    
  5. In your Scene's script, add or amend these 2 functions with these codes.

         
	   func _ready():
           $CounterTimer.start()
         
	 
	   func _process(delta):
           var time = str($CounterTimer.counter_time)
	       $Label.text = time  
	 
  1. The time variable will return the timer's time in a preformatted string as such...

    10:59:999

    The first number before a : symbol is mInutes ex. 10 The second number after the first : symbol is seconds ex. 59 The third number after the second : symbol is milliseconds ex. 999

  2. You can not get the individual settings of Minutes, Seconds, or Milliseconds from the time variable in the example above. However, you can get the Minutes, Seconds, or Milliseconds using the individual properties of the CounterTimer node in the script of your Scene where the CounterTimer node is a child of.

          
	   var minutes
	   var seconds
	   var milliseconds
	   
	   func _process():
           minutes = $CounterTimer.minutes
           seconds = $CounterTimer.minutes
           milliseconds = $CounterTimer.minutes 
	  
     Then you can use and/or format and display each as you want!

	 
8. It's simple!

About

This is a custom timer node that can do both countdowns and coups.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published