Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » If () Then block stops part way through?
- oldscratchy
-
4 posts
If () Then block stops part way through?
Rather than execute to the end, my if () then block appears to stop execution.
See http://scratch.mit.edu.ezproxyberklee.flo.org/projects/10742289/
What am I missing…?
See http://scratch.mit.edu.ezproxyberklee.flo.org/projects/10742289/
What am I missing…?
- drmcw
-
1000+ posts
If () Then block stops part way through?
You're doing too much in the whack event. Just record the hit there. You need to move the show hide logic into the when green flag clicked event and have a loop (eg repeat until moles = 5) in there to do all the show and hiding. I can see what you're trying to do but it's not a good way to go. Basically you don't want an event to be running (the whack event) when you could receive another one.
If you want some ideas then look at this fruit splat game which was written for version 1.4 but has a similar idea. All the control for what appears and when is in the Stage.
If you want some ideas then look at this fruit splat game which was written for version 1.4 but has a similar idea. All the control for what appears and when is in the Stage.
Last edited by drmcw (June 10, 2013 09:51:16)
- oldscratchy
-
4 posts
If () Then block stops part way through?
Thanks for your reply but I don't understand how to put hide/show code in the startup block
I need to act on the whack event as well as record it. If I don't do it in the event (where it logically belongs) then how do I trigger the actions?
Will check out the fruit splat thanks. (Please note that no actual moles are harmed playing my game)
I need to act on the whack event as well as record it. If I don't do it in the event (where it logically belongs) then how do I trigger the actions?
Will check out the fruit splat thanks. (Please note that no actual moles are harmed playing my game)
Last edited by oldscratchy (June 10, 2013 09:51:25)
- oldscratchy
-
4 posts
If () Then block stops part way through?
Thanks, I moved the detecting which mole was hit to the hammer sprite (as in Fruit Splat) and used separate broadcast messages to each mole.
It now seems to work pretty well but I'm going to try putting my moles into an array, so the code isn't duplicated,
It now seems to work pretty well but I'm going to try putting my moles into an array, so the code isn't duplicated,
- oldscratchy
-
4 posts
If () Then block stops part way through?
Version 2 is much better, with cloned moles appearing at random across the lawn
http://scratch.mit.edu.ezproxyberklee.flo.org/projects/10755214/
http://scratch.mit.edu.ezproxyberklee.flo.org/projects/10755214/
- Discussion Forums
- » Help with Scripts
-
» If () Then block stops part way through?