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

#1 2011-09-01 16:57:37

webinzat100
New Scratcher
Registered: 2010-06-23
Posts: 1

How to make a sprite do a specific action if...

How do you make a sprite do a specific action only if it's clicked on the first time?
             For example, I want a sprite to broadcast a message so another sprite will recieve the  broadcast and pop up. But I only want the first sprite to broadcast  a message the first time its clicked.

Offline

 

#2 2011-09-01 17:05:46

owetre18
Scratcher
Registered: 2009-07-01
Posts: 1000+

Re: How to make a sprite do a specific action if...

webinzat100 wrote:

How do you make a sprite do a specific action only if it's clicked on the first time?
             For example, I want a sprite to broadcast a message so another sprite will recieve the  broadcast and pop up. But I only want the first sprite to broadcast  a message the first time its clicked.

I'll tell you. I just have to make the script first. Be back in a sec.

Edit: here.

http://i.imgur.com/G6uld.gif

Last edited by owetre18 (2011-09-01 17:11:17)

Offline

 

#3 2011-09-01 17:07:37

ImagineIt
Scratcher
Registered: 2011-02-28
Posts: 1000+

Re: How to make a sprite do a specific action if...

[blocks]<when green flag clicked>
<set{ Clicked?  }to( no

<when[ object ]clicked>
<if <(  <<{ Clicked?  }>= no>  )>>
<broadcast[ broadcast
<end>
<set{ Clicked?  }to( yes
[/blocks]

Last edited by ImagineIt (2011-09-01 17:08:18)

Offline

 

#4 2011-09-01 17:09:27

laptop97
Scratcher
Registered: 2011-06-27
Posts: 1000+

Re: How to make a sprite do a specific action if...

Start
Wait Until <<Touching[mouse-pointer]>and <Mouse down>>
Broadcast[Whatever Broadcast]

Offline

 

#5 2011-09-01 19:12:36

MoreGamesNow
Scratcher
Registered: 2009-10-12
Posts: 1000+

Re: How to make a sprite do a specific action if...

laptop97 wrote:

Start
Wait Until <<Touching[mouse-pointer]>and <Mouse down>>
Broadcast[Whatever Broadcast]

Nope: you can hold your mouse down and drag it over the sprite and still activate the script.


http://images2.layoutsparks.com/1/218929/rubiks-cube-animated-rotating.gif
"Cogito ergo sum" --  I think, therefore I am

Offline

 

#6 2011-09-01 21:28:35

laptop97
Scratcher
Registered: 2011-06-27
Posts: 1000+

Re: How to make a sprite do a specific action if...

New Script

Start
Forever If<Touching [mouse-pointer]>
  Wait Until <mouse down>
  If <Touching[mouse-pointer]>
    Broadcast[Whatever Broadcast]
    Stop Script

Last edited by laptop97 (2011-09-01 21:29:26)

Offline

 

#7 2011-09-01 21:57:08

4lover
Scratcher
Registered: 2010-04-24
Posts: 500+

Re: How to make a sprite do a specific action if...

well if you want the first thing to hide it would be alot easier


Check out this awesome new zombie-cod type of game: http://scratch.mit.edu/projects/4lover/1975649

Offline

 

#8 2011-09-01 23:36:58

Thescratch3
Scratcher
Registered: 2011-06-14
Posts: 1000+

Re: How to make a sprite do a specific action if...

4lover wrote:

well if you want the first thing to hide it would be alot easier

That is not the case here though.

Solution:

When Flag Clicked
forever
if touching mouse pointer and mouse down
broadcast message
stop script


View my projects. Or face The scratch curse! (Get it?)
http://i56.tinypic.com/2cdk8hy.png

Offline

 

Board footer