This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2010-01-13 19:23:43

PrimusGod
Scratcher
Registered: 2009-11-16
Posts: 10

Use the same button more than once?

Hi. I want to be able to press the 'n' key in order to shift to another Stage background. However, there are five stage backgrounds in all for this, and I don't know how to use 'n' to switch between these for the game.

Does anyone know the scripts necessary for this? Your answer is appreciated!


Hard artichokes, rarely keep
Hungarian elephants, Singapore sleep

Offline

 

#2 2010-01-13 19:34:38

Ace-of-Spades
Scratcher
Registered: 2010-01-08
Posts: 1000+

Re: Use the same button more than once?

Okay Use the sub-heading 'When key 'n' Press' and then put the Next Background, which you can find in the background's Looks tab.


11110010100011010100011010101000100011011011001010111100101000110101000110101010001000110110110010101111001010001101010001101010100010001101101100101011110010100011010100011010101000100011011011001010
110101010010001010101010101010101010101010100110101010010101010010101001101011010101010010101010101

Offline

 

#3 2010-01-13 23:02:55

PrimusGod
Scratcher
Registered: 2009-11-16
Posts: 10

Re: Use the same button more than once?

I  did as you suggested, and I found that this also worked (Minus the sound blocks):

http://fc08.deviantart.net/fs71/f/2010/013/3/a/Scratch_Blocks_by_PrimusGod.png

Thank you for the help!

Last edited by PrimusGod (2010-01-13 23:03:12)


Hard artichokes, rarely keep
Hungarian elephants, Singapore sleep

Offline

 

#4 2010-01-13 23:09:51

Larry828
Scratcher
Registered: 2007-05-30
Posts: 100+

Re: Use the same button more than once?

Ace-of-Spades wrote:

Okay Use the sub-heading 'When key 'n' Press' and then put the Next Background, which you can find in the background's Looks tab.

This is a good solution.  Note that it will cycle through the backgrounds in the order you have created them in the project.  As many times as you press the "n" key. 

If by some chance you want to *return* to a background before moving on then insert a copy of the earlier background later in the series and it will come up.

If you want more control than that, then other sprites would probably have to "broadcast" a background change based on some action elsewhere in the project.

Offline

 

#5 2010-01-13 23:52:17

PrimusGod
Scratcher
Registered: 2009-11-16
Posts: 10

Re: Use the same button more than once?

Larry828 wrote:

Ace-of-Spades wrote:

Okay Use the sub-heading 'When key 'n' Press' and then put the Next Background, which you can find in the background's Looks tab.

This is a good solution.  Note that it will cycle through the backgrounds in the order you have created them in the project.  As many times as you press the "n" key. 

If by some chance you want to *return* to a background before moving on then insert a copy of the earlier background later in the series and it will come up.

If you want more control than that, then other sprites would probably have to "broadcast" a background change based on some action elsewhere in the project.

Exactly. I had an arrow sprite that I was going to use based on the backgrounds. I ended up only using two scripts, one which involved using the last background to broadcast to it to hide. :D Thanks guys.

Last edited by PrimusGod (2010-01-13 23:52:26)


Hard artichokes, rarely keep
Hungarian elephants, Singapore sleep

Offline

 

#6 2010-01-13 23:57:18

PrimusGod
Scratcher
Registered: 2009-11-16
Posts: 10

Re: Use the same button more than once?

Ace-of-Spades wrote:

Okay Use the sub-heading 'When key 'n' Press' and then put the Next Background, which you can find in the background's Looks tab.

Also, please realize I have other backgrounds included other than these five, so this might be a drawback to what you are suggesting.


Hard artichokes, rarely keep
Hungarian elephants, Singapore sleep

Offline

 

#7 2010-01-14 00:25:42

martianshark
Scratcher
Registered: 2008-03-24
Posts: 1000+

Re: Use the same button more than once?

PrimusGod wrote:

I  did as you suggested, and I found that this also worked (Minus the sound blocks):

http://fc08.deviantart.net/fs71/f/2010/013/3/a/Scratch_Blocks_by_PrimusGod.png

Thank you for the help!

That's not exactly a great way to do it. A better way would be this:

<when green flag clicked>
<forever>
<wait until> <key[ n ]pressed?>
<switch to costume[ Directions1
<wait until> <key[ n ]pressed?>
<switch to costume[ Directions2
<wait until> <key[ n ]pressed?>
<switch to costume[ Directions3
<wait until> <key[ n ]pressed?>
<switch to costume[ Directions4
<wait until> <key[ n ]pressed?>
<switch to costume[ Directions5
<end>


http://img.geocaching.com/stats/img.aspx?txt=martianshark&amp;uid=e6cdc2c8-2476-4abd-9994-27f857396579&amp;bg=1

Offline

 

#8 2010-01-14 00:37:34

deatheater
Scratcher
Registered: 2008-04-11
Posts: 1000+

Re: Use the same button more than once?

martianshark wrote:

PrimusGod wrote:

I  did as you suggested, and I found that this also worked (Minus the sound blocks):

http://fc08.deviantart.net/fs71/f/2010/ … musGod.png

Thank you for the help!

That's not exactly a great way to do it. A better way would be this:

<when green flag clicked>
<forever>
<wait until> <key[ n ]pressed?>
<switch to costume[ Directions1
<wait until> <key[ n ]pressed?>
<switch to costume[ Directions2
<wait until> <key[ n ]pressed?>
<switch to costume[ Directions3
<wait until> <key[ n ]pressed?>
<switch to costume[ Directions4
<wait until> <key[ n ]pressed?>
<switch to costume[ Directions5
<end>

[/blocks]
Actually that would be worse (it would skip straight through), a better way, would be

to add a <wait until><<  <not> <key[ n ]pressed?> >> [/blocks]

in-between each

<switch to costume[ ??? [/blocks] and <wait until> <key[ n ]pressed?> [/blocks]

Last edited by deatheater (2010-01-14 00:39:52)

Offline

 

#9 2010-01-14 00:55:32

greenflash
Scratcher
Registered: 2009-05-27
Posts: 1000+

Re: Use the same button more than once?

Here's the simplest one yet:
[blocks]
<when green flag clicked>
<forever>
<if><key[  ]pressed?>
<next costume>(background)
<wait until><<  <not>  >><key[  ]pressed?>
<end>
<end>
[/blocks]


http://i48.tinypic.com/2wrkirk.pnghttp://i46.tinypic.com/6r5zk7.pnghttp://i45.tinypic.com/2vtxr1t.png

Offline

 

#10 2010-01-29 01:07:34

martianshark
Scratcher
Registered: 2008-03-24
Posts: 1000+

Re: Use the same button more than once?

deatheater wrote:

martianshark wrote:

PrimusGod wrote:

I  did as you suggested, and I found that this also worked (Minus the sound blocks):

http://fc08.deviantart.net/fs71/f/2010/ … musGod.png

Thank you for the help!

That's not exactly a great way to do it. A better way would be this:

<when green flag clicked>
<forever>
<wait until> <key[ n ]pressed?>
<switch to costume[ Directions1
<wait until> <key[ n ]pressed?>
<switch to costume[ Directions2
<wait until> <key[ n ]pressed?>
<switch to costume[ Directions3
<wait until> <key[ n ]pressed?>
<switch to costume[ Directions4
<wait until> <key[ n ]pressed?>
<switch to costume[ Directions5
<end>

[/blocks]
Actually that would be worse (it would skip straight through), a better way, would be

to add a <wait until><<  <not> <key[ n ]pressed?> >> [/blocks]

in-between each

<switch to costume[ ??? [/blocks] and <wait until> <key[ n ]pressed?> [/blocks]

Oh yeah. I forgot about that part.


http://img.geocaching.com/stats/img.aspx?txt=martianshark&amp;uid=e6cdc2c8-2476-4abd-9994-27f857396579&amp;bg=1

Offline

 

Board footer