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

#1 2012-04-27 11:01:51

s1484052
New Scratcher
Registered: 2012-04-22
Posts: 1

how to make clicking a sprite affect a different sprite

im making a "you're the cameraman" interactive game, i want to click a "RECORD" button (sprite)  and have it turn on the flashing "REC" (sprite).  how do i do this?

Offline

 

#2 2012-04-27 12:25:24

PhirripSyrrip
Scratcher
Registered: 2012-02-11
Posts: 100+

Re: how to make clicking a sprite affect a different sprite

Try this

when [record button v] clicked//for the record button
set [recording v] to [yes]
when gf clicked//for the REC sprite
set [recording v] to [0]
forever
if <(recording)=[yes]>
do whatever
end
end
This is better than using broadcasts as you can then make something that sets the variable "Recording" to 0, meaning that the REC sprite stops doing whatever it's doing.


http://i46.tinypic.com/ao03lk.png

Offline

 

#3 2012-04-27 14:17:43

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

Re: how to make clicking a sprite affect a different sprite

PhirripSyrrip wrote:

Try this

when [record button v] clicked//for the record button
set [recording v] to [yes]
when gf clicked//for the REC sprite
set [recording v] to [0]
forever
if <(recording)=[yes]>
do whatever
end
end
This is better than using broadcasts as you can then make something that sets the variable "Recording" to 0, meaning that the REC sprite stops doing whatever it's doing.

You want to be careful of having too many forever loops though, because that can really bog down your project. Which one should be used differs from case-to-case, of course.


http://www.blocks.scratchr.org/API.php?action=random&amp;return=image&amp;link1=http://i.imgur.com/OZn2RD3.png&amp;link2=http://i.imgur.com/duzaGTB.png&amp;link3=http://i.imgur.com/CrDGvvZ.png&amp;link4=http://i.imgur.com/POEpQyZ.png&amp;link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

#4 2012-04-27 15:53:44

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

Re: how to make clicking a sprite affect a different sprite

Both techniques have there place, but in general I would recommend Broadcast + When I Receive instead. (These blocks are both in the Control section.)


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

 

#5 2012-04-27 16:51:07

turkey3
Scratcher
Registered: 2011-12-04
Posts: 500+

Re: how to make clicking a sprite affect a different sprite

ManaUser wrote:

Both techniques have there place, but in general I would recommend Broadcast + When I Receive instead. (These blocks are both in the Control section.)

Here's how:

When [record button v] clicked
Broadcast [recording v]
Then in the REC picture sprite:
When I receive [recording v]
Show  //you have this because you want the REC to show up
Do anything else if needed

Offline

 

Board footer