Discuss Scratch

jakesmithey
New Scratcher
3 posts

Switching back to the previous background.

Hello,
I'm currently making a maze game for coursework and have stumbled upon a issue. (Not been using scratch for long) I have made a help background for if players get stuck, they press H and are re-directed to a help page for 10 seconds. However after them ten seconds I need it to switch back to the previous background. My game has over a dozen levels so I couldn't use switch to background _ or switch to background -1. If possible could you please tell me a way to switch to a previous background.

Thanks,
Jake
DotDash
Scratcher
1000+ posts

Switching back to the previous background.

do this:

switch backdrop to (Backdrop # - 1)

Last edited by DotDash (July 24, 2013 14:53:58)

Psiborg
Scratcher
500+ posts

Switching back to the previous background.

DotDash wrote:

do this:

switch backdrop to (Backdrop # - 1)
I think Jake needs to go back to the backdrop the user was previously on, rather than the previous one in the list. Therefore a solution would be to store the backdrop # in a variable before switching to the help backdrop and then switch the backdrop back to the number previously stored afterwards.
footsocktoe
Scratcher
1000+ posts

Switching back to the previous background.

I agree. When the user presses H, then the current backdrop # is stored in a variable so it can be retrieved when H is over.
jakesmithey
New Scratcher
3 posts

Switching back to the previous background.

Ahhh, thanks guys!
ZeldaFett
New Scratcher
1 post

Switching back to the previous background.

How would you do this? I'm trying to make a pause menu so when you press the play sprite it will go back to the Backdrop or “level” you were on before the pause. I just don't know exactly how to store the variable. Actually, I know nothing about variables. A little help?

Last edited by ZeldaFett (Sept. 2, 2013 03:08:02)

drmcw
Scratcher
1000+ posts

Switching back to the previous background.

ZeldaFett wrote:

How would you do this? I'm trying to make a pause menu so when you press the play sprite it will go back to the Backdrop or “level” you were on before the pause. I just don't know exactly how to store the variable. Actually, I know nothing about variables. A little help?


In Data press make a variable and give the variable a name like Last Backdrop. Press ok and you should end up with some new blocks. You might want to untick the checkbox to hide the variable but there are also blocks to achieve this if you want to do that in your scripts. Then to remember the backdrop use
setLast Backdroptobackdropname

then when you have to return use

switchbackdroptoLastBackdrop

Last edited by drmcw (Sept. 2, 2013 06:24:12)

turkey3
Scratcher
1000+ posts

Switching back to the previous background.

DotDash wrote:

do this:

switch backdrop to (Backdrop # - 1)
And actually, in the switch backdrop to () block, there is an option called “previous backdrop” (which does your workaround). However, it is not in the switch costume to () block
curiouscrab
Scratcher
500+ posts

Switching back to the previous background.

turkey3 wrote:

DotDash wrote:

do this:

switch backdrop to (Backdrop # - 1)
And actually, in the switch backdrop to () block, there is an option called “previous backdrop” (which does your workaround). However, it is not in the switch costume to () block
You mean
switchbackdroptoprevious backdrop
SCRATHCREATOR950
Scratcher
12 posts

Switching back to the previous background.

Here is the answer
whenclickedforeverswitchbackdroptoprevious backdrop
its under the line where
switchbackdroptobackdrop1
HyperPixel
Scratcher
46 posts

Switching back to the previous background.

In Data press make a variable and give the variable a name like
LastBackdrop
Press ok and you should end up with some new blocks.
. . .before changing the costume to the help screen use this code to save the current backgroundsetLast Backdroptobackdropname. . .use the code for switching to help screen below this codeswitchbackdroptoLastBackdropthen when you want to return to the maze costume

Last edited by HyperPixel (April 9, 2014 00:30:36)

FlashX73
Scratcher
8 posts

Switching back to the previous background.

Simply make the help option a sprite with the following:
when hkeypressedshowwait10secshide

It doesn't have to be a backdrop…unless it's something different you're talking about, please let me know…
SolarSon
Scratcher
100+ posts

Switching back to the previous background.

SCRATHCREATOR950 wrote:

Here is the answer
whenclickedforeverswitchbackdroptoprevious backdrop
its under the line where
switchbackdroptobackdrop1

Last edited by SolarSon (July 4, 2015 21:11:12)

jshrubb
Scratcher
1 post

Switching back to the previous background.

HOW DO I HAVE SO I CAN CHANGE TO DIFFERENT BACKDROP ARFTER 10 SECONDS
Qwertsick
Scratcher
51 posts

Switching back to the previous background.

jshrubb wrote:

HOW DO I…

Please don't necropost. to answer your question tho, do this:

foreverwait10secsswitchbackdroptopickrandom1tohowever many backdrops you have

Last edited by Qwertsick (April 27, 2018 16:44:24)

cheetosftw
Scratcher
1 post

Switching back to the previous background.

hi
deck26
Scratcher
1000+ posts

Switching back to the previous background.

cheetosftw wrote:

hi
Please don't spam.
Sunflower9567
Scratcher
4 posts

Switching back to the previous background.

Hi. I am a fairly new Scratcher, and I have a question. If I'm testing my game and I want to start the game from the beggining, it starts me from where I left off on that background. I need help PLEASE!
Thanks,
Love,
@Sunflower9567
mlcreater
Scratcher
1000+ posts

Switching back to the previous background.

Sunflower9567 wrote:

Hi. I am a fairly new Scratcher, and I have a question. If I'm testing my game and I want to start the game from the beggining, it starts me from where I left off on that background. I need help PLEASE!
Thanks,
Love,
@Sunflower9567
Don't necropost; check the dates first. Please create your own topic.
deck26
Scratcher
1000+ posts

Switching back to the previous background.

Sunflower9567 wrote:

Hi. I am a fairly new Scratcher, and I have a question. If I'm testing my game and I want to start the game from the beggining, it starts me from where I left off on that background. I need help PLEASE!
Thanks,
Love,
@Sunflower9567
Ideally yes, create your own topic but this is a simple one. In a green flag script tell your project what the starting conditions should be.

It's actually good practice to initialise everything before any game play.

whenclicked one green flag in a project is actually enoughbroadcastinitialiseandwait wait ensures all receivers complete before we continuebroadcastready

Powered by DjangoBB