Discuss Scratch

lion525
New to Scratch
7 posts

Pause Button

I'm making a game and i am pretty sure someone doesnt want to restart it every time they go to the bathroom or something that doesn't involve them to play. I want to find out how to make a pause button. Take a look at my game if it helps to understand what i mean.
DudePotato3
Scratcher
63 posts

Pause Button

An easy thing to do would be to like implement a sprite that looks like a pause button and to if mouse down and if touching mouse pointer it will broadcast a message with the broadcast block and when the other parts of your game receive it they freeze

Me: Be a dude and play these!
Guy: WHAT YA GOIN ON ABOUT MATE
Me: Look down there! Game links!
Guy: oh


Space Shooter (2 Player Game) // Defend The Castle // Diamond Clicker
footsocktoe
Scratcher
1000+ posts

Pause Button

lion525 wrote:

I'm making a game and i am pretty sure someone doesnt want to restart it every time they go to the bathroom or something that doesn't involve them to play. I want to find out how to make a pause button. Take a look at my game if it helps to understand what i mean.

If you haven't finished your game then don't waste your time worrying about a pause button. First you have to make the game. Then you can worry about little details.


SHOOT THE SPACE MONSTERS! ….. A game everyone can play! Bright colors, bonky sounds!
THE 12 BALLS OF CRAZY AL ……. New scrolling adventure game!

Shadoex
Scratcher
23 posts

Pause Button

Make a variable, name it. Let's use “pause” as an example.
(pause)
When the Green Flag is clicked, you can set pause to 0, so that the game is not paused when you start.
when green flag clicked
set [pause v] to []
Note: 0 = False, 1 = True (Booleans)
If pause = 0, then the game continues. If pause = 1, then it will pause the game.
You will now want a sprite that changes the pause value. A script to toggle pause can look something like this:
when this sprite clicked
if <(pause) = [0]> then
set [pause] to [1]
else
set [pause] to [0]
end
wait (1) secs

Now, in order to pause the content of your game, put this script around everything you want paused.
if <(pause) = [0]> then 
Run the usual script.
else
Leave this empty unless you want to have a pause menu.
end

Example:
Let's say you have a script for moving upwards.
when [space v] key pressed
change y by (100)

If you do not want this to happen when the player is paused, simply insert the previously shown script.
when [space v] key pressed
if <(pause) = [0]> then
change y by (100)
else

end

This should be a functional pause button. Have fun!

Last edited by Shadoex (July 13, 2016 22:23:35)

lion525
New to Scratch
7 posts

Pause Button

I tryed it and it didnt work do you think something might have happened Shadoex. Maybe I missed pplaced something. Do you have any more detail i need to know.
lion525
New to Scratch
7 posts

Pause Button

I tried that but it didnt work maybe you could make a simple game and share it and give me a link. @Shadoex
Shadoex
Scratcher
23 posts

Pause Button

Sorry for the late reply. You probably put the script inside of your backpack– The variable itself did not function because I entered the Scratch block as an example you could copy.

Solution: The script will work if you delete and remake the “pause” variable.

Here's the use of this Pause Button.

~ Shadoex

Last edited by Shadoex (Aug. 1, 2016 02:12:24)

superl2
Scratcher
39 posts

Pause Button

This is the method I use, and I guarantee that it works! (Remember; only put the pause condition on the absolutely necessary scripts, to reduce lag.)

Come check out PixelShare! It's a project where you can paint pictures and share them with the world! Or if you want, you can browse through everyone else's pictures!

({® Licensed Scratcher-who-used-1.4-before-this-account Club Member ®(())} :: ring) // Put this as your signature to show that you used Scratch 1.4
gtoal
Scratcher
1000+ posts

Pause Button

If you structure your code so that only one script has a main loop and every other action takes place when you broadcast ‘execute next frame’, then by pausing the main loop, you can freeze multiple actions at once. An example program that has a lot of sprites which uses this technique is https://scratch.mit.edu/projects/117474890/ - space will halt all the action.
scratchastroLOL
Scratcher
1000+ posts

Pause Button

You can do this:

forever
if <(pause) = [1]> then
stop [other scripts in sprite v]
wait until <not <(pause) = [1]>>
broadcast [resume v]
end
end

Last edited by scratchastroLOL (June 27, 2020 16:36:48)

pugguy1000
Scratcher
3 posts

Pause Button

I could Help if you could send me a message

Powered by DjangoBB