Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How do you pause a game?
- jess_is_awesome
-
Scratcher
5 posts
How do you pause a game?
I have no idea how to freeze the screen without using
stop [ v]
- D-Mate19
-
Scratcher
100+ posts
How do you pause a game?
Try this
Hen add this to your sprites
when [p] key pressed
switch backdrop to [ pause game backdrop]
Hen add this to your sprites
when backdrop switches to [ pause game backdrop]
stop [this script v]
Else
Last edited by D-Mate19 (March 24, 2016 20:09:50)
- bastiaan1200
-
Scratcher
17 posts
How do you pause a game?
when [P v] key pressed
set [Pause v] to [ 1]
wait until <mouse down?>
set [Pause v] to [ 0]
In other sprite
wait until <[Pause] = [ 0]>
Last edited by bastiaan1200 (March 25, 2016 07:50:45)
- Wong2016
-
Scratcher
24 posts
How do you pause a game?
when [P v] key pressed
set [Pause v] to [ 1]
wait until <mouse down?>
set [Pause v] to [ 0]
In other spritewait until <[Pause] = [ 0]>
wait until <(Pause) = [ 0]>
- _Mento_
-
Scratcher
6 posts
How do you pause a game?
when [P v] key pressed
set [Pause v] to [ 1]
wait until <mouse down?>
set [Pause v] to [ 0]
In other spritewait until <[Pause] = [ 0]>wait until <(Pause) = [ 0]>[/quote]
Yup
Last edited by _Mento_ (March 25, 2016 11:16:33)
- gtoal
-
Scratcher
1000+ posts
How do you pause a game?
This is where good design pays off. If your code contains lots and lots of infinite loops, stopping everything is tricky. This is just one reason why most games are coded with one main loop that controls all the action. Then you have one place where you can easily insert a pause command.
- DisneyArtz
-
New Scratcher
3 posts
How do you pause a game?
Put in anything:
Put in pause screen:
Put in all other sprites:
when green flag clicked
forever
if <key [p v] pressed?> then
broadcast [pause v]
end
end
Put in pause screen:
when I receive [pause v]
show
go to front
when green flag clicked
hide
when green flag clicked
forever
if <key [space v] pressed?> then
hide
end
end
Put in all other sprites:
when [p v] key pressed
hide
wait until <key [space v] pressed?>
show
- MA006
-
Scratcher
4 posts
How do you pause a game?
Why dosen't this work?
when I receive [ v]
if <key [ v] pressed?> then
if <[(pause)] = [0]> then
set [(pause) v] to [1]
end
if <(pause) = [1]> then
set [(pause) v] to [0]
end
end
- deck26
-
Scratcher
1000+ posts
How do you pause a game?
Why dosen't this work?Please start your own topic rather than necroposting.when I receive [ v]
if <key [ v] pressed?> then
if <[(pause)] = [0]> then
set [(pause) v] to [1]
end
if <(pause) = [1]> then
set [(pause) v] to [0]
end
end
Think through your script - what happens when you run it with pause = 0?
- Mist_2019
-
Scratcher
5 posts
How do you pause a game?
Try thiswhen [p] key pressed
switch backdrop to [ pause game backdrop]
Hen add this to your spriteswhen backdrop switches to [ pause game backdrop]
stop [this script v]
Else
what if I want to make sure that you can't move anything while the pause game backdrop is shown
like, for instance, if you have a sprite that constantly moves and points to your mouse, and you want it to stop moving to your mouse while the game is paused
- notgoodatc0de
-
Scratcher
100+ posts
How do you pause a game?
I'm pretty sure that will happen because of the stop this script block. As long as you add it to the scripts, I think it should work (i don't know tho).Try thiswhen [p] key pressed
switch backdrop to [ pause game backdrop]
Hen add this to your spriteswhen backdrop switches to [ pause game backdrop]
stop [this script v]
Else
what if I want to make sure that you can't move anything while the pause game backdrop is shown
like, for instance, if you have a sprite that constantly moves and points to your mouse, and you want it to stop moving to your mouse while the game is paused
- Oumuamua
-
Scratcher
1000+ posts
How do you pause a game?
Please do not revive old topics. Thanks
Below a pretty useful advice already posted in this topic
Below a pretty useful advice already posted in this topic
This is where good design pays off. If your code contains lots and lots of infinite loops, stopping everything is tricky. This is just one reason why most games are coded with one main loop that controls all the action. Then you have one place where you can easily insert a pause command.
- PartyFlamingo124
-
Scratcher
2 posts
How do you pause a game?
Put in anything:when green flag clicked
forever
if <key [p v] pressed?> then
broadcast [pause v]
end
end
Put in pause screen:when I receive [pause v]
show
go to front
when green flag clicked
hide
when green flag clicked
forever
if <key [space v] pressed?> then
hide
end
end
Put in all other sprites:when [p v] key pressed
hide
wait until <key [space v] pressed?>
show
Thanks, this really usefull, I'll tell you if it works or not, also because I have 3.0
- PartyFlamingo124
-
Scratcher
2 posts
How do you pause a game?
1 thing: I do NOT have 0 posts, ok? I don't know why it says that. Yeah, it doesn't work at all, it basiccally makes everything disappear and the pause screen doesn't even come up.Put in anything:when green flag clicked
forever
if <key [p v] pressed?> then
broadcast [pause v]
end
end
Put in pause screen:when I receive [pause v]
show
go to front
when green flag clicked
hide
when green flag clicked
forever
if <key [space v] pressed?> then
hide
end
end
Put in all other sprites:when [p v] key pressed
hide
wait until <key [space v] pressed?>
show
Thanks, this really usefull, I'll tell you if it works or not, also because I have 3.0
- Yeetoburro1
-
Scratcher
1000+ posts
How do you pause a game?
This is NOT HELPINGDude, this thread is from 2016
- Vibrato
-
Scratcher
1000+ posts
How do you pause a game?
HelloPlease don't post on old topics. You have just bumped someone needing help off the front page, making it far less likely for them to get help.
- Discussion Forums
- » Help with Scripts
-
» How do you pause a game?