Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Adding a timer with sprites
- Intelligent684
-
Scratcher
100+ posts
Adding a timer with sprites
So this is one of the topics I'm not exactly sure on, I'm confused how I would make a timer without using the ugly variable text having just like
“Minutes: 5” or the shortened version of the shown variable
I want to have like a good looking timer (Minutes and seconds)
Can someone help with this? The project is down below but it won't really help
“Minutes: 5” or the shortened version of the shown variable
I want to have like a good looking timer (Minutes and seconds)
Can someone help with this? The project is down below but it won't really help

- Tu2tl3Gamz
-
Scratcher
100+ posts
Adding a timer with sprites
I’d help but I’m using my phone right now and the code is really complicated lol
I’ll follow the discussion and come back later lol
I’ll follow the discussion and come back later lol
Last edited by Tu2tl3Gamz (Oct. 1, 2024 22:32:01)
- Jlerpy
-
Scratcher
1000+ posts
Adding a timer with sprites
Have a search for text engines, then you can plug (timer) into it
- Tu2tl3Gamz
-
Scratcher
100+ posts
Adding a timer with sprites
Im on my computer!
this will take a sec lol
this will take a sec lol
- Tu2tl3Gamz
-
Scratcher
100+ posts
Adding a timer with sprites
Countdown Timer
This sounds like a great idea to make games feel more fast paced! To do this, all you need to do is a few easy steps!
Note: Im asuming you dont know how to do anything im about to say so i will go into full detail. you can skip over things if you like!
And thats that! Just three easy steps and now you have a working countdown timer! And the cool part is, you can change or add stuff as you please!
Just make sure to credit me if you use this!
And let me know if you have questions!
This sounds like a great idea to make games feel more fast paced! To do this, all you need to do is a few easy steps!
Note: Im asuming you dont know how to do anything im about to say so i will go into full detail. you can skip over things if you like!

Step One
The first step to making an amazing countdown timer is to make your costumes!
You will need the numbers 0-9 and a colon ( : )
You can do this yourself or there are resources online! just search “font download” to find a font you like!
Make sure that the costumes are red, you will find out why later in step 3
Step Two
Before we get to use the costumes you just made, we need to make our variables!
You will need two variables - Seconds and Minutes.
Set up the script like so:when green flag clicked
set [ Seconds] to [0]
set [ Minutes] to [5]
forever
wait (1) secs
change [ Seconds] by (-1)
end
when green flag clicked
forever
if <<(Minutes) > [0]> and <(seconds) < [1]>> then
change [ minutes] by (-1)
set [ seconds] to [59]
end
if <<(Minutes) < [0]> and <(seconds) < [1]>> then
stop [ all]
end
end
Step Three
Now that we have the variable scripts, we can now start work on the scripts that will show a nice countdown timer!
You will be creating your own blocks, so try to follow along!define Clone Costume: (costume) xPos (xPos) yPos (yPos) Line Space (Line Space)
broadcast [ delete clones]
go to x: (xPos) y: (yPos)
set [ #] to [1]
repeat (length of (Costume)) // it shows up as a variable but its the "costume" from the custom block
look color (0) brightness (100) size (150) // this will be a block shown later
switch costume to [ (letter (#) of (costume))] // i dont know why this doesnt show correctly but its the "letter 1 of apple" block
create clone of [ myself]
change x by ((Line Space) * (size))
change [ #] by (1)
end
define Look Color: (color) brightness: (brightness) size: (size)
clear graphic effects
set [ color] effect to (color)
set [ brightness] effect to (brightness)
set size to (size) %
Since you should have already done the code for the timer, now we just have to put them together!when green flag clicked
forever
Clone Costume: (join (Minutes) (join [:] (Seconds))) xPos (Your X Value) yPos (Your Y Value) Line Space (0.25)
end
Dont forget these two!when I receive [ Delete Clones]
delete this clone
when I start as a clone
forever
show
end
And thats that! Just three easy steps and now you have a working countdown timer! And the cool part is, you can change or add stuff as you please!

Just make sure to credit me if you use this!
And let me know if you have questions!
- RokCoder
-
Scratcher
1000+ posts
Adding a timer with sprites
The suggestions to use a text engine (or simplified version thereof) will yield the best results but the display you already have matches the output you're using for score, health, etc. Are you planning on customising them all?
An alternative might be to display a shortened form of a new variable and customise its contents. For example -
An alternative might be to display a shortened form of a new variable and customise its contents. For example -
set [displayTime v] to (join (join (Minutes) (:)) (Time))
- Tu2tl3Gamz
-
Scratcher
100+ posts
Adding a timer with sprites
The suggestions to use a text engine (or simplified version thereof) will yield the best results but the display you already have matches the output you're using for score, health, etc. Are you planning on customising them all?
An alternative might be to display a shortened form of a new variable and customise its contents. For example -set [displayTime v] to (join (join (Minutes) (:)) (Time))
The display time variable is definitely a smarter way to do that lol
- Intelligent684
-
Scratcher
100+ posts
Adding a timer with sprites
Alright, sorry I haven't been on my computer it was late at the time y'all were talking last night. Uhh so basically I just wanted a cooler looking timer because the one I have is very ugly…. I don't need to customize them all but if it's not a super hard thing to do, then that could be something I start working on soon. I'm just not very fluent in the language of variables and my blocks lol.
Edit: I don't exactly need a countdown timer, I just like having a timer there because it kind of fits the game I have. Although, I'm screenshotting what you said incase a future project I make needs one, I have an awesome countdown timer right there so thanks so much.
And yes I will credit you, I don't credit a lot of people because I use my own code most of the time lol… Every time I do get a suggestion from someone else I always credit it so don't worry I 100% will
Edit: I don't exactly need a countdown timer, I just like having a timer there because it kind of fits the game I have. Although, I'm screenshotting what you said incase a future project I make needs one, I have an awesome countdown timer right there so thanks so much.
And yes I will credit you, I don't credit a lot of people because I use my own code most of the time lol… Every time I do get a suggestion from someone else I always credit it so don't worry I 100% will

Last edited by Intelligent684 (Oct. 2, 2024 12:37:29)
- Discussion Forums
- » Help with Scripts
-
» Adding a timer with sprites



