ロング体験会 ご応募受付中です

Coding TIME LIMIT : Step Up Your Scratch Game

Scratch 制限時間を設けよう

I will show you how to create a time limit, which is often used when creating games with Scratch.

How to create TIME LIMIT on scratch games
目次

Step1 Make a variable “TIME”

Press the “Make a Variable”,
then name the variable “TIME” ( whatever ).

Be sure to select “For all sprites”

new variable

Step2 Set the initial TIME

This step you will set the initial “TIME” in seconds.

If you want to set 60 sec, set TIME to 60 .

set time to 60

You can write the code wherever,
but in general, write it on Stage or main sprite (Sprite1) .

In this post, I write the code on Sprite1 (Cat).

Finally, place the code below “when green flag clicked” code.

when flag clicked

Step3 Decrease the TIME by 1 second until it reaches 0

I’d like to decrease the TIME by 1 for each second.

Repeat as follows 60 times (until the TIME reaches 0)
wait 1 sec. → change TIME by -1

Here’s the code.

repeat until

Step4 Closing logic

This is the last step.
I write the logic when the TIME reaches 0.

You write “stop all” at the bottom.
What you put in front of it is up to you depending on the program.

Cat says “Time is up!”
Change the backdrop.

Whatever

closing code

Entire Code

Here’s the entire code.

entire code

Scratch is developed by the Lifelong Kindergarten Group at the MIT Media Lab.
See http://scratch.mit.edu.

シェアおねがいします

この記事を書いた人

目次