Discuss Scratch

jc_thom
New Scratcher
7 posts

How do I create a restart/retry button?

Hello, I'm trying to create my very first Scratch game and I'm having trouble trying to create a restart/retry button. I'm trying to create an even simpler version of Chrome Dino, so at the end of the game there should be a “Retry” button that you're able to click, but I'm unable to figure out how to code the sprite to do any of that. I've watched some videos and browsed online but can't seem to find a solution. I keep reading up on broadcasts but I'm not understanding how those work or how to use them.


Any help would be much appreciated,
Thanks.
shinykrystal
Scratcher
49 posts

How do I create a restart/retry button?

broadcast [Restart v]
when I receive [Restart v]
Then just put in all that you want to restart
jc_thom
New Scratcher
7 posts

How do I create a restart/retry button?

shinykrystal wrote:

broadcast [Restart v]
when I receive [Restart v]
Then just put in all that you want to restart
Hi, thanks so much for your reply. I've tried this and can't seem to get anywhere.

On the Dino Sprite I added;
when I receive [Restart v]
go to x: () y: (0)
set [Score v] to [0]

There are 7 total sprite's I have. 1 is the Dino itself, 4 are different cacti objects to jump over, 1 is the background, and the other is the retry button. I have everything else in working order, just need to get the retry button working, I have 0 code for it so far.

I'm not sure where to add the other block or if I'm even doing this correctly.

Last edited by jc_thom (Jan. 11, 2023 17:07:17)

cookieclickerer33
Scratcher
1000+ posts

How do I create a restart/retry button?

jc_thom wrote:

Hello, I'm trying to create my very first Scratch game and I'm having trouble trying to create a restart/retry button. I'm trying to create an even simpler version of Chrome Dino, so at the end of the game there should be a “Retry” button that you're able to click, but I'm unable to figure out how to code the sprite to do any of that. I've watched some videos and browsed online but can't seem to find a solution. I keep reading up on broadcasts but I'm not understanding how those work or how to use them.


Any help would be much appreciated,
Thanks.
Just tell them to press the green flag again and use the
stop [All v]
Block
groggs
Scratcher
100+ posts

How do I create a restart/retry button?

cookieclickerer33 wrote:

Just tell them to press the green flag again and use the
This doesn't seem to be a solution for the current issue.
cookieclickerer33
Scratcher
1000+ posts

How do I create a restart/retry button?

groggs wrote:

cookieclickerer33 wrote:

Just tell them to press the green flag again and use the
This doesn't seem to be a solution for the current issue.
?
It restarts the game tho
groggs
Scratcher
100+ posts

How do I create a restart/retry button?

cookieclickerer33 wrote:

It restarts the game tho
The purpose of this topic is to have a “Restart” button, which restarts some specific scene once it's clicked, however, the solution you've suggested is a message to tell others to click the green flag, which is not what's exactly needed.
drum1234567
Scratcher
17 posts

How do I create a restart/retry button?

move ((0) / (1)) steps
say [it's time for space]
groggs
Scratcher
100+ posts

How do I create a restart/retry button?

drum1234567 wrote:

move ((0) / (1)) steps
say [it's time for space]
Please do not block spam. There's a sticky topic for Testing ScratchBlocks If that's what you're looking for.
American-jedi66
Scratcher
31 posts

How do I create a restart/retry button?

IDK what these other guys are talking about but all you need to do is make a new sprite, make it whatever you want it to look like, and make it broadcast a message (the same message should be broadcast when the green flag clicked) when clicked. boom done, you can make it show up when you die or whatever by using another message (replace every green flag with this message)

when this sprite clicked
broadcast [restart]

when I receive [restart]
set [score] to [0]
go to x: (wherever) y: (wherever)
say [whatever else you need here]

when green flag clicked
broadcast [restart]

Last edited by American-jedi66 (Jan. 11, 2023 18:00:31)

jc_thom
New Scratcher
7 posts

How do I create a restart/retry button?

cookieclickerer33 wrote:

jc_thom wrote:

Hello, I'm trying to create my very first Scratch game and I'm having trouble trying to create a restart/retry button. I'm trying to create an even simpler version of Chrome Dino, so at the end of the game there should be a “Retry” button that you're able to click, but I'm unable to figure out how to code the sprite to do any of that. I've watched some videos and browsed online but can't seem to find a solution. I keep reading up on broadcasts but I'm not understanding how those work or how to use them.


Any help would be much appreciated,
Thanks.
Just tell them to press the green flag again and use the
stop [All v]
Block
Thanks for your reply.

Maybe I was unclear with my issue. I'm trying to make a “Retry”/“Restart” button that pops up and can be clicked on once the player hits one of the objects. I already have it coded to where the game stops once the Dino hits an object. I think I've chosen something a bit too hard for my first ever project, as I've got some other issues that I'd like to fix, but I'm trying the best I can to find a solution that works for this, first.
jc_thom
New Scratcher
7 posts

How do I create a restart/retry button?

American-jedi66 wrote:

IDK what these other guys are talking about but all you need to do is make a new sprite, make it whatever you want it to look like, and make it broadcast a message (the same message should be broadcast when the green flag clicked) when clicked. boom done, you can make it show up when you die or whatever by using another message (replace every green flag with this message)

when this sprite clicked
broadcast [restart]

when I receive [restart]
set [score] to [0]
go to x: (wherever) y: (wherever)
say [whatever else you need here]

when green flag clicked
broadcast [restart]

Hi, thanks for your reply. I'm still having trouble understanding how these broadcasts blocks work; I've tried your solution and still am unable to get it working. I've made my project shareable, maybe seeing the insides will help.

Link: https://scratch.mit.edu/projects/786348997
groggs
Scratcher
100+ posts

How do I create a restart/retry button?

jc_thom wrote:

Hi, thanks for your reply. I'm still having trouble understanding how these broadcasts blocks work; I've tried your solution and still am unable to get it working. I've made my project shareable, maybe seeing the insides will help.

Link: https://scratch.mit.edu/projects/786348997
You seem to use the event block for key detection, which doesn't seem to go well.
This event block would still run even if the project is stopped, which simply means that you still can jump even if the game is ended.

However, you're also stopping the project, if the Cactus is touched, that could stop other scripts to run, including broadcasts, your button doesn't also seem to show for the player when finished. My advice, instead of stopping everything if the player touches a Cactus, pop the retry button up and wait until it's clicked, to start the game again.
jc_thom
New Scratcher
7 posts

How do I create a restart/retry button?

groggs wrote:

jc_thom wrote:

Hi, thanks for your reply. I'm still having trouble understanding how these broadcasts blocks work; I've tried your solution and still am unable to get it working. I've made my project shareable, maybe seeing the insides will help.

Link: https://scratch.mit.edu/projects/786348997
You seem to use the event block for key detection, which doesn't seem to go well.
This event block would still run even if the project is stopped, which simply means that you still can jump even if the game is ended.

However, you're also stopping the project, if the Cactus is touched, that could stop other scripts to run, including broadcasts, your button doesn't also seem to show for the player when finished. My advice, instead of stopping everything if the player touches a Cactus, pop the retry button up and wait until it's clicked, to start the game again.

Yes, that is another issue that I have to fix, I think I tried to tackle a project a little bit more advanced than I realized. I used this video from the Scratch Team (https://www.youtube.com/watch?v=1jHvXakt1qw) to implement the jumping. I tried different code to see if I could get it to stop jumping when you touch a cactus, but the best I could get was you could jump once more and then it would stop, but the code felt clunky and wasn't running how I wanted it to originally run, so I scrapped it. The score also goes up whenever you jump, so I need to also figure out how to add points only when a cactus is jumped over. I've got a lot to do, but I thought I'd work on this first.

But that is also my issue, I don't know how to make the button pop up and make it clickable to restart the game.

To be quite honest this whole thing is driving me a bit insane; I can't seem to understand what I am doing.
Tems_student
Scratcher
94 posts

How do I create a restart/retry button?

Quickly explain to me the game Idea and share some scripts through scratchblocks. I think you are creating similar to the dinosaur game offline for google.
jc_thom
New Scratcher
7 posts

How do I create a restart/retry button?

Tems_student wrote:

Quickly explain to me the game Idea and share some scripts through scratchblocks. I think you are creating similar to the dinosaur game offline for google.

Hi, yes that's precisely it. Here is the link: https://www.youtube.com/watch?v=1jHvXakt1qw
jc_thom
New Scratcher
7 posts

How do I create a restart/retry button?

jc_thom wrote:

Tems_student wrote:

Quickly explain to me the game Idea and share some scripts through scratchblocks. I think you are creating similar to the dinosaur game offline for google.

Hi, yes that's precisely it. Here is the link: https://www.youtube.com/watch?v=1jHvXakt1qw

Sorry I linked the YouTube video again. Here is the link to the project: https://scratch.mit.edu/projects/786348997
jdh5778
Scratcher
14 posts

How do I create a restart/retry button?

I have a problem, I'm making a flappy bird kind of game, and the retry button should appear when i touch a spike, but each time you press on it the spikes just start randomly spawning everywhere i just can't understand why, it happens to me all the time in all of my games with both retry and home buttons.

If someone can figure out the problem please help me
the game : https://scratch.mit.edu/projects/819415642/
jdh5778
Scratcher
14 posts

How do I create a restart/retry button?

jc_thom wrote:

Hello, I'm trying to create my very first Scratch game and I'm having trouble trying to create a restart/retry button. I'm trying to create an even simpler version of Chrome Dino, so at the end of the game there should be a “Retry” button that you're able to click, but I'm unable to figure out how to code the sprite to do any of that. I've watched some videos and browsed online but can't seem to find a solution. I keep reading up on broadcasts but I'm not understanding how those work or how to use them.


Any help would be much appreciated,
Thanks.
if you put the link for the game, i'll see if I can fix it
medians
Scratcher
1000+ posts

How do I create a restart/retry button?

See:

Powered by DjangoBB