Sprite click detection not working


#1

I am using mBlock to make a program that makes a mBot run around and make noise. To make it start, I used a “when this sprite clicked” event block and added code under the event. After doing so, I checked if it worked and it didn’t. I know the code under it works, only the click event doesn’t. How can I make this work?

P.S: This is for a project for school so please respond ASAP.


#2

@superrbo,
Upload a copy of your code so the folks on the forum can see what you are working with.
Mike


#3

Sorry, I forgot to check the forum.
Here it is:
thenapotron.sb2 (84.1 KB)


#4

@superrbo: Nice program. I’m running your project in v3.2.1 (just became available) and I can see the “Start” button changing when I click it. The “set time” feature seems to work too.
However, I notice that if I don’t release the “click” fast enough that the Start/Stop button changes multiple times.

This is a common problem when detecting if something like a button is “down”. The code might detect that it’s down multiple times before the user releases the button. Look inside the “When flag clicked” ‘forever’ loop and think about how frequently you really need to check the Start/Stop button.
Hint: You’ll probably want to look in some other places in your code at your use of the “forever” loop. Remember that forever is a very long time…

Good luck with your school project!