This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2012-05-29 19:22:02

Firedrake969
Scratcher
Registered: 2011-11-24
Posts: 1000+

Alternate clicking method

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)


Click the sign.
https://s3.amazonaws.com/eterna/eterna2/logo2.png

Offline

 

#2 2012-05-29 20:45:15

ManaUser
Scratcher
Registered: 2009-03-11
Posts: 100+

Re: Alternate clicking method

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.


http://i.imgur.com/SPYSM.gif http://i.imgur.com/t9k1Z.gif http://i.imgur.com/OwYVa.gif http://i.imgur.com/0qlZq.gif

Offline

 

#3 2012-05-29 21:08:24

amcerbu
Scratcher
Registered: 2009-07-21
Posts: 500+

Re: Alternate clicking method

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

 

Board footer