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

#1 2009-03-04 19:31:44

Jello715
Scratcher
Registered: 2008-10-11
Posts: 95

Making a "when sprite clicked" script?

Can you do it without the "when sprite clicked" block? If you have "if mouse down and touching mouse pointer", it's not exactly the same as the "when sprite clicked" block. I can click somewhere else on the stage, then touch the sprite with the mouse pointer and it will activate the script, but I don't want that. I want it so that you have to keep the mouse on the button while clicking!  big_smile

Offline

 

#2 2009-03-04 22:09:09

Jello715
Scratcher
Registered: 2008-10-11
Posts: 95

Re: Making a "when sprite clicked" script?

Well?

Offline

 

#3 2009-03-04 22:12:50

abeair
Scratcher
Registered: 2008-07-19
Posts: 100+

Re: Making a "when sprite clicked" script?

I don't think so.


http://dragcave.net/image/NPtA.gif
http://www.danasoft.com/sig/ObamaLovesMacs.jpg

Offline

 

#4 2009-03-05 05:40:55

yambanshee
Scratcher
Registered: 2007-11-06
Posts: 500+

Re: Making a "when sprite clicked" script?

just use a script like if (touching mouse AND mouse is clicked)
if this is not what you asked for, please explain better

Offline

 

#5 2009-03-05 20:15:07

Jello715
Scratcher
Registered: 2008-10-11
Posts: 95

Re: Making a "when sprite clicked" script?

Jello715 wrote:

I can click somewhere else on the stage, then touch the sprite with the mouse pointer and it will activate the script

It's not the same as "when sprite clicked".

Offline

 

#6 2009-03-05 20:26:44

technoguyx
Scratcher
Registered: 2008-10-18
Posts: 1000+

Re: Making a "when sprite clicked" script?

Use two scripts:
[blocks]<when green flag clicked>
<forever>
<if><< << <mouse down?> <and> <touching[ mouse-pointer >> <and> <( <{ click }> <=> 1 )> >>
Insert whatever you want here
<end>
<end>

And the click script:
<when green flag clicked>
<set{ click }to( 0
<forever>
<wait until><mouse down?>
<set{ click }to( 1
<set{ click }to( 0
<wait until><<  <not> <mouse down?> >>
<end>[/blocks]

I'm not sure if that will work, I usually don't test scripts I post on the forums... Still, you should try it


http://getgnulinux.org/links/en/linuxliberated_4_78x116.png

Offline

 

#7 2009-03-06 06:51:02

bosox397
Scratcher
Registered: 2008-02-17
Posts: 1000+

Re: Making a "when sprite clicked" script?

technoguyx wrote:

Use two scripts:
[blocks]<when green flag clicked>
<forever>
<if><< << <mouse down?> <and> <touching[ mouse-pointer >> <and> <( <{ click }> <=> 1 )> >>
Insert whatever you want here
<end>
<end>

And the click script:
<when green flag clicked>
<set{ click }to( 0
<forever>
<wait until><mouse down?>
<set{ click }to( 1
<set{ click }to( 0
<wait until><<  <not> <mouse down?> >>
<end>[/blocks]

I'm not sure if that will work, I usually don't test scripts I post on the forums... Still, you should try it

yeah that will work.  it will work better with a wait .01 seconds inbetween the set click to 1 set click to 2


Dear Scratch Users,
I'm done with scratch, or at least making projects. I have made one last big game, thats both fun and teaches a lesson about water. It'd mean a lot if you gave me feedback.                              http://scratch.mit.edu/projects/bosox397/569201

Offline

 

#8 2009-03-07 16:32:59

floppy_gunk
Scratcher
Registered: 2008-11-14
Posts: 500+

Re: Making a "when sprite clicked" script?

Here is how I would do it:

[blocks]<when green flag clicked>
<forever if><< <touching[ mouse-pointer <and> <not> <mouse down?> >> >>
<wait( 0.01 )secsc>
<if><< <touching[ mouse-pointer <and> <mouse down?> >>
DO WHATEVER WHEN CLICKED
<end>
<end>[/blocks]


http://img163.imageshack.us/img163/1917/2856lg.jpg Get it now!  smile

Offline

 

#9 2009-03-07 20:25:06

Jello715
Scratcher
Registered: 2008-10-11
Posts: 95

Re: Making a "when sprite clicked" script?

Thanks technoguyx  big_smile

Offline

 

#10 2009-03-08 07:53:58

bhz
Scratcher
Registered: 2008-07-06
Posts: 100+

Re: Making a "when sprite clicked" script?

a better way
<when green flag clicked>
<forever>
     <if><touching[ mouse pointer <and><not><mouse down?>
          <wait until><mouse down?>
          <SCRIPTS HERE>

Last edited by bhz (2009-03-08 07:54:43)

Offline

 

Board footer