Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » My code won't start when green flag is pressed
- MarsBURGER27
- Scratcher
26 posts
My code won't start when green flag is pressed
The code I have is:
When green flag is clicked
(Forever) Change position to x-180 y13
Move forward 10
Move forward 10
Move forward 10
Change to background 2
Change position to x-180 y13
Move forward 10
Move forward 10
Move forward 10
Change to background 4
Change position to x-180 y13
When I press the green flag, this doesn't work
Why?
When green flag is clicked
(Forever) Change position to x-180 y13
Move forward 10
Move forward 10
Move forward 10
Change to background 2
Change position to x-180 y13
Move forward 10
Move forward 10
Move forward 10
Change to background 4
Change position to x-180 y13
When I press the green flag, this doesn't work
Why?
- treinslave
- Scratcher
23 posts
My code won't start when green flag is pressed
Advance 10
Advance 10
Advance 10
Change to background 2
Change position to x-180y13
Advance 10
Advance 10
Advance 10
Change to background 4
Change position to x-180y13
“Advance 10
Advance 10
Advance 10
Change to background 4
Position x-180y13 ”
It works if you repeat the “Advance 10” three times instead of using the block three times. For the time being, it wakes up all the way before the first advance 10.
Advance 10
Advance 10
Change to background 2
Change position to x-180y13
Advance 10
Advance 10
Advance 10
Change to background 4
Change position to x-180y13
“Advance 10
Advance 10
Advance 10
Change to background 4
Position x-180y13 ”
It works if you repeat the “Advance 10” three times instead of using the block three times. For the time being, it wakes up all the way before the first advance 10.
- treinslave
- Scratcher
23 posts
My code won't start when green flag is pressed
Actually, I'm Japanese.
Where are you from?
Finally I will speak in Japanese.
「すごい?」
Where are you from?
Finally I will speak in Japanese.
「すごい?」
- deck26
- Scratcher
1000+ posts
My code won't start when green flag is pressed
How do you know it doesn't work? You don't appear to be using the pen so the sprite will obey all those blocks before the screen is refreshed and the loop runs again. Try adding a wait in the middle of the loop or changing the script so the end position is not the same every time you reach the end of the loop.
- Jlerpy
- Scratcher
500+ posts
My code won't start when green flag is pressed
The whole thing is happening faster than you can see. Yes, add some waits in there.
Look what happens if you swap out your “switch background to” blocks for “next backdrop” and add an extra backdrop.
Look what happens if you swap out your “switch background to” blocks for “next backdrop” and add an extra backdrop.
- MarsBURGER27
- Scratcher
26 posts
My code won't start when green flag is pressed
Thanks for all these responses, guys! I've only been here at Scratch for one day and I can already see that it is a really active and supportive community!
Thank you for the help, and you're right I should add a wait, but what do you mean by “using the pen”? I have sprites, if that's what you're asking.
I am American and I only speak English (as well as a little bit of Spanish), so I have no idea what you just said. But hello and thanks for the help! Actually, I'm Japanese.
Where are you from?
Finally I will speak in Japanese.
「すごい?」
How do you know it doesn't work? You don't appear to be using the pen so the sprite will obey all those blocks before the screen is refreshed and the loop runs again. Try adding a wait in the middle of the loop or changing the script so the end position is not the same every time you reach the end of the loop.
Thank you for the help, and you're right I should add a wait, but what do you mean by “using the pen”? I have sprites, if that's what you're asking.
- deck26
- Scratcher
1000+ posts
My code won't start when green flag is pressed
It looked like you might be trying to draw a line but obviously not.How do you know it doesn't work? You don't appear to be using the pen so the sprite will obey all those blocks before the screen is refreshed and the loop runs again. Try adding a wait in the middle of the loop or changing the script so the end position is not the same every time you reach the end of the loop.
Thank you for the help, and you're right I should add a wait, but what do you mean by “using the pen”? I have sprites, if that's what you're asking.
Ignore your code and tell us what you're trying to achieve. Code runs very quickly and the frame is only redrawn at the end of the forever loop so all you'll see is the sprite at that position and background 4 - you won't see anything else that happens during the loop since Scratch is not redrawing the screen after every block and even if it was it would be so quick you'd only see one state.
- Discussion Forums
- » Help with Scripts
- » My code won't start when green flag is pressed