Pages: 1
Topic closed
So, I'm working on a language project. One of the activities requires the user to click the correct fruit sprites from a list, which will then move to the basket sprite. Once all the fruit sprites are touching the basket sprite, it's supposed to broadcast a message which will trigger the fruit sprites and basket to disappear and change the background. This is my script for one of the "correct" fruit sprites (the ones that are supposed to be clicked) :
[blocks]<when[ Sprite30 ]clicked>
<switch to costume[ costume5 ]>
<wait(0.25)secsc>
<switch to costume[ costume6 ]>
<go to[ Sprite27 ]>[/blocks]
That script works. All 4 of the correct sprites are programmed like this, so they all go to the basket sprite (Sprite27). (The costume blocks are just for "prettiness" in the final result.) Here is the coding that doesn't work for Sprite27:
[blocks]<if><touching[ Sprite30 ]>
<if><touching[ Sprite33 ]>
<if><touching[ Sprite34 ]>
<if><touching[ Sprite35 ]>
<broadcast[ firstcorrect ]>[/blocks]
I have it programmed so the stage background changes and the sprites disappear, but when I click the fruits it won't work. Am I missing a block?
Offline
If the sprites are hidden, they're not being touched, no matter where they are...it sounds like this might be your problem, but I can't be sure.
Offline
No, that's not it. They don't hide until they're touching. Thanks anyways.
Offline
Use
[blocks] <wait until> << << << <touching[ Sprite30 ]> <and> <touching[ Sprite33 ]> >> <and> <touching[ Sprite34 ]> >> <and> <touching[ Sprite35 ]> >> [/blocks]
Or, in simpler terms,
Wait until touching sprite 30 AND touching sprite 33 AND touching sprite 34 AND touching sprite 35.
Reason: once you start the project, the if statements would have been evaluated. therefore, there is only once chance at beating it, and that is in less than a second after the script is triggered unless single-stepping is on.
Last edited by SJRCS_011 (2012-01-13 20:44:40)
Offline
SJRCS_011, thanks but I'm afraid that it still doesn't work. I think I need to add a block like <when green flag clicked> to correct it, but I really don't want to do that
Offline
That's what I was inferring. Have it under the green flag hat block, and it'll work.
Or at least should work.
Offline
it will be easier if you name the sprites descriptively like "fruit20" or "basket"
Offline
joefarebrother wrote:
it will be easier if you name the sprites descriptively like "fruit20" or "basket"
...How does that matter?
Offline
Topic closed
Pages: 1