Most people know the
when SpriteX clicked, but I use a different way:
if <<touching mouse> and <mouse down?>> do stuff. This is just to help a script if you want to start with a broadcast or clicking the flag.
Last edited by Firedrake969 (2012-05-29 19:23:22)
Offline
Technically it's not quite the same a clicking. Your way will also detect if someone points at it while the mouse button is already held down, whereas that wouldn't be considered a click. Of course sometimes that's what you want, like in a painting type situation, so they're both useful techniques.
Offline
When I'm writing a script for clicking a sprite (and I don't want the "When Sprite Clicked" hat), I use the following (actually, Firedrake969, I used this method when I added the pause button to your Air Raid project). This script goes in the button sprite.
when I receive [CheckPaused v] // A main sprite broadcasts CheckPaused. if < touching [mouse pointer v] ? > if < mouse down? > if < (mouseDownLastFrame) = [false] > switch to costume [Pressed v] if < (Paused?) = [true] > set [Paused? v] to [false] else if < (Paused?) = [false] > set [Paused? v] to [true] end end set [mouseDownLastFrame v] to [true] end else switch to costume [HoveredOver v] end else switch to costume [Default v] if < mouse down? > set [mouseDownLastFrame v] to [true] end end if < not < mouse down? > > set [mouseDownLastFrame v] to [false] end
Last edited by amcerbu (2012-05-29 21:08:58)
Offline