Pages: 1
Topic closed
Some of my kids were making a "shooter" game where the crosshair moved with the mouse and you only got a hit when the crosshair and ball were touching AND you clicked to shoot (mouse button down).
However, tomorrow when going to keep score, it was clearly visible that you collected points for as long as the mouse button was held down and the sprites intersected, so if you just moved around with the button down you ran up the score. Even a short click often generated several points each time. I posted an example, tennis sniper.
Ideally you only want one point per click.
In "real" mouse usage, the action for the click doesn't actually take place until the button is released, so as to only generate one event. Would it be possible to get a "mouse released" sensor so this would work properly?
I can envision a messy workaround with some kind of timer or counter before it will register another hit, but that seems awfully complicated. Am I missing something more simple?
Offline
I can think of a work-around that only involves adding one variable. Basically, it causes you to have to do a mouse up before you can get any more points, but it probably isn't the best solution. You can see the project and script at http://scratch.mit.edu/projects/paulmedwalhelp/8942
Paulmedwal
Offline
I use a "firing" variable. It starts at zero.
When mouse down:
-if firing=0
- set firing to 1
- (run your firing script)
- (set firing = 0)
Offline
You may be able to get what you want with
forever if mouse down
do firing action
wait until not mouse down
Offline
Thanks Kevin, that last works well and adds the least amount of complexity. I think I'll post in the enhancements thread elsewhere my wish for "mouse up" or perhaps "mouse click" to be added to Scratch.
Offline
Topic closed
Pages: 1