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

#1 2012-10-20 14:01:09

udiamr
New Scratcher
Registered: 2012-10-20
Posts: 2

Need Sprite to react to touch ad then continue moving in the same way

Hi,

Whatever code I tried, I was unable to get it right.

This is the latest version:

when gf clicked
set size to 20%
hide
wait (1) secs
show
forever
glide (4) secs to x: pick random (260) to (-260) y: pick random (110) to (-100)
if <touching [sprite3]?
Broadcast [event 2]
What I want to achive: this code block is of a sprite that movesin a random patern.
There is another sprite (sprite3) that moves verticaly. If they touch, I need the touching to create an event and the movement of the sprite to continue.

The difficulties I'm facing: either the sprite stops moving after reacting to the touch, or it keeps moving without sensing the touch.

Thanks!

Offline

 

#2 2012-10-20 16:29:40

Tastycakelover
Scratcher
Registered: 2012-09-04
Posts: 16

Re: Need Sprite to react to touch ad then continue moving in the same way

Try adding a 'stop script' block after the 'broadcast event 2' block, like this:

when gf clicked
set size to (20) %
hide
wait (1) secs
show
forever
glide [4] secs to x: < (pick random (260) to (-260) > y: < (pick random (110) to (-100) >
if < touching [Sprite3 v] >
broadcast [event 2 v]
stop script
end 
end
Maybe that will help.  cool

Offline

 

#3 2012-10-20 16:55:57

ErnieParke
Scratcher
Registered: 2010-12-03
Posts: 1000+

Re: Need Sprite to react to touch ad then continue moving in the same way

Tastycakelover wrote:

Try adding a 'stop script' block after the 'broadcast event 2' block, like this:

when gf clicked
set size to (20) %
hide
wait (1) secs
show
forever
glide (4) secs to x: (pick random (260) to (-260)) y: (pick random (110) to (-100))
if < touching [Sprite3 v]?>
broadcast [event 2 v]
stop script
end
Maybe that will help.  cool

I fixed your scratchblocks code, though that still wouldn't work. Here's what I would use:

when gf clicked
set size to (20) %
hide
wait (1) secs
show
forever
glide (4) secs to x: (pick random (260) to (-260)) y: (pick random (110) to (-100))

when gf clicked 
forever
if < touching [Sprite3 v]?>
broadcast [event 2 v]
end
I hope that this helps!

Last edited by ErnieParke (2012-10-20 16:56:26)


http://i46.tinypic.com/35ismmc.png

Offline

 

#4 2012-10-21 00:38:47

udiamr
New Scratcher
Registered: 2012-10-20
Posts: 2

Re: Need Sprite to react to touch ad then continue moving in the same way

Thank you so much Ernie! It does work!
I spent 6 hours yesterday trying to figure out whats wrong  smile

Offline

 

#5 2012-10-21 08:24:47

ErnieParke
Scratcher
Registered: 2010-12-03
Posts: 1000+

Re: Need Sprite to react to touch ad then continue moving in the same way

udiamr wrote:

Thank you so much Ernie! It does work!
I spent 6 hours yesterday trying to figure out whats wrong  smile

That's a lot of work. I can already see that you're very persistant. Anyway, your welcome!


http://i46.tinypic.com/35ismmc.png

Offline

 

Board footer