Discuss Scratch

bobbyit1
Scratcher
8 posts

How do I make a pause menu?

So, I have a remixed version of a game, and I am trying to make it unique to me. I am trying to make a pause menu, but don't know where to start. Here is the link, then maybe someone could remix it in, then I could copy that into my current game.

https://scratch.mit.edu/projects/23805729/

Last edited by bobbyit1 (Feb. 25, 2016 16:38:57)


Just a couple games that I made that are actually good. (the rest are pretty bad)
Battle X: https://scratch.mit.edu/projects/104643434/
Slime Shooter: https://scratch.mit.edu/projects/23805729/
mrbobbygreathead
Scratcher
1000+ posts

How do I make a pause menu?

I might have a go…

We need you to tell the scratch team we want nested lists! (Also known as first class lists, multidimensional lists or just lists inside lists). Support now!
Please try out SSMS, the radical new approach to Scratch music! Compose, share and use music all inside scratch!
BY147258369
Scratcher
1000+ posts

How do I make a pause menu?

bobbyit1 wrote:

So, I have a remixed version of a game, and I am trying to make it unique to me. I am trying to make a pause menu, but don't know where to start. Here is the link, then maybe someone could remix it in, then I could copy that into my current game.

https://scratch.mit.edu/projects/23805729/
Here is an idea.
when this sprite clicked
go to front
switch costume to [Pause v]
broadcast [Pause v]

Then you can add what you want to buy in

asivi
Scratcher
1000+ posts

How do I make a pause menu?

Create a new variable named Pause
Create a backdrop named Pause
Create a button named Pause with these scripts
when green flag clicked
set [Pause v] to [off]
when this sprite clicked
set [Pause v] to [on]
switch backdrop to [Pause v]

In others sprites use the next block at the first place inside the scripts that you want to pause
wait until <(Pause) = [off]>
Also you can create a Resume button
when this sprite clicked
set [Pause v] to [off] // don´t include the above script in this

Last edited by asivi (Feb. 25, 2016 21:32:31)

asivi
Scratcher
1000+ posts

How do I make a pause menu?

If you want to use a key instead button' sprites, for example “p”, you can do it whith this script
when [p v] key pressed
if <(Pause) = [off]> then
set [Pause v] to [on]
switch backdrop to [Pause v]
else
set [Pause v] to [off]
switch backdrop to [your previous backdrop v]
end
wait until <not <key [p v] pressed?>>

In others sprites use the next block at the first place inside the scripts that you want to pause
wait until <(Pause) = [off]>

Last edited by asivi (Feb. 25, 2016 23:52:58)

bobbyit1
Scratcher
8 posts

How do I make a pause menu?

asivi wrote:

If you want to use a key instead button' sprites, for example “p”, you can do it whith this script
when [p v] key pressed
if <(Pause) = [off]> then
set [Pause v] to [on]
switch backdrop to [Pause v]
else
set [Pause v] to [off]
switch backdrop to [your previous backdrop v]
end
wait until <not <key [p v] pressed?>>

Would that stop all of the processes running at that time?

Just a couple games that I made that are actually good. (the rest are pretty bad)
Battle X: https://scratch.mit.edu/projects/104643434/
Slime Shooter: https://scratch.mit.edu/projects/23805729/
Birdlegs
Scratcher
1000+ posts

How do I make a pause menu?

You could lock every single thing running a loop under an “if (pause = off)” to stop all processes running at the time, though things like waits will still “wait,” and the loops will still complete the run they're on after you pause.

Like this:

forever

if <(pause) = [off ]> then

move (10) steps
pen down
turn ccw (180) degrees

end

end

repeat until <>

if <(pause) = [off ]> then

end

Under the forever loop above, even if you pause after “move ten steps,” the program will still complete the loop, running “pen down” and “turn 180 degrees” even AFTER the pause. Once those are done running, though, they will not run again until pause = off.

Last edited by Birdlegs (Feb. 25, 2016 23:44:22)


Get a sweet lick of my new game right here! It's a tasty one!
bobbyit1
Scratcher
8 posts

How do I make a pause menu?

JoeyTheChicken wrote:

You could lock every single thing running a loop under an “if (pause = off)” to stop all processes running at the time, though things like waits will still “wait,” and the loops will still complete the run they're on after you pause.

Like this:

forever

if <(pause) = [off ]> then

move (10) steps
pen down
turn ccw (180) degrees

end

end

repeat until <>

if <(pause) = [off ]> then

end

Under the forever loop above, even if you pause after “move ten steps,” the program will still complete the loop, running “pen down” and “turn 180 degrees” even AFTER the pause. Once those are done running, though, they will not run again until pause = off.
What sprite would I put it under?

Just a couple games that I made that are actually good. (the rest are pretty bad)
Battle X: https://scratch.mit.edu/projects/104643434/
Slime Shooter: https://scratch.mit.edu/projects/23805729/
zp100
Scratcher
100+ posts

How do I make a pause menu?

bobbyit1 wrote:

What sprite would I put it under?

Each sprite that needs it.

For one sprite, you might have
forever
if <(pause) = [off ]> then
move (10) steps
pen down
turn ccw (180) degrees
end
end
And another might have
forever
if <(pause) = [off ]> then
move (10) steps
next costume
turn cw (10) degrees
change x by (12)
end
end

Logic will get you from A to B. Imagination will take you everywhere.

- Albert Einstein
zp100
Scratcher
100+ posts

How do I make a pause menu?

Another thing you could do is
forever
move (10) steps
next costume
turn cw (10) degrees
change x by (12)
wait until <(pause) = [off]>
end

Last edited by zp100 (Feb. 26, 2016 04:28:02)


Logic will get you from A to B. Imagination will take you everywhere.

- Albert Einstein
asivi
Scratcher
1000+ posts

How do I make a pause menu?

bobbyit1 wrote:

asivi wrote:

If you want to use a key instead button' sprites, for example “p”, you can do it whith this script
when [p v] key pressed
if <(Pause) = [off]> then
set [Pause v] to [on]
switch backdrop to [Pause v]
else
set [Pause v] to [off]
switch backdrop to [your previous backdrop v]
end
wait until <not <key [p v] pressed?>>

Would that stop all of the processes running at that time?
Scratch is not able to make a real pause (freezing temporally), sounds player can't be paused, the built-in timer can't be stopped or paused either, the method above can simulate a pause, but like JoeyTheChicken said the currently running tasks inside loops make its job until the end of those loops.
Other solution maybe to broadcast a message to stop scripts and re-run its whith another message.
Greets.
SuperFireLavaBoy
Scratcher
4 posts

How do I make a pause menu?

thank you for this, but how can you make it so, the player and other sprites stop when the pause menu is up?
Anonymous1212144
Scratcher
100+ posts

How do I make a pause menu?

When I receive [pause v]
display pause screen
stop [all v]
When I receive [start v]
hide pause screen
...

Last edited by Anonymous1212144 (Feb. 10, 2019 17:58:13)

Brahvim
Scratcher
4 posts

How do I make a pause menu?

asivi wrote:

Scratch is not able to make a real pause (freezing temporally), sounds player can't be paused, the built-in timer can't be stopped or paused either, the method above can simulate a pause.
Respected asivi,
Pause =
(Pause)
I think That We Can Make A Timer ourselves With this code -:
when green flag clicked
forever
wait (1) secs
change [_Timer_ v] by (1)
end
After That, If we Pause The Game, We Can Do This -:
when green flag clicked
if <(Pause) = [1]> then
set [_Time_Storer_ v] to (_Timer_)
end
After that, when The Game Is Resumed,
We Can Do This,
when green flag clicked
if <(Pause) = [0]> then
set [_Timer_ v] to (_Time_Storer_)


end
Also, in Many Games now-a-days, Music Clips Restart After Pausing The Game.
Else We Can Have Scratch Music(Music that is Produced on Scratch With Scripts) Which, I think could (Probably) Be Paused By this Script-:
If <(Pause) = [1]> then
repeat until <(Pause) = [0]>

rest for <1 beats>

end

Note: “Pause = 1” means “Paused” and “Paused = 0” means “Running”

I am not Sure If The Music Script Works, But Pretty Sure that others Will work properly.
And Since This was my Third (Scratch) Forum Post, I
Thank You All.


By The Way, I was here because I had the same thought as ‘bobyit1’ (How To Create A Pause Menu) so, i Would Like To Thank You All Once Again, As This Forum Helped me Too!

XD!! Joke For You All: LoL! I Helped This Forum, and, it Helped Me!
(Sorry For going Off-Topic With That Joke.)

Last edited by Brahvim (March 1, 2019 06:13:17)

Powered by DjangoBB