This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.
  • Index
  •  » New Scratchers
  •  » Moving 2 sprites when 1 is clicked, any help would be appreciated.

#1 2009-08-06 07:22:48

mark7182
Scratcher
Registered: 2009-08-06
Posts: 1

Moving 2 sprites when 1 is clicked, any help would be appreciated.

Hi, i'm wokring on my first scratch project and i am struggling to create the code that for example if sprite 1 was clicked then sprite 2 would move under sprite 1 then once this is achieved sprite 1 will now move.

Thanks

Offline

 

#2 2009-08-09 13:07:55

jacool
Scratcher
Registered: 2008-01-25
Posts: 1000+

Re: Moving 2 sprites when 1 is clicked, any help would be appreciated.

I don't really understand what you mean,
I'm not very good at english could you please write what you want the code to do in step by step.


http://i571.photobucket.com/albums/ss159/JacobKar/svensktiger-1.png

Offline

 

#3 2009-08-14 03:39:43

WeirdF
Scratcher
Registered: 2009-05-31
Posts: 1000+

Re: Moving 2 sprites when 1 is clicked, any help would be appreciated.

Try this, and just replace the question marks with where you want sprite 2 and 1 to go:

Sprite 1's script:
[blocks]
<when[ sprite1 ]clicked>
<broadcast[ move under ]and wait c>
<glide( 1 )secs to x sad  ? )y sad  ?
[/blocks]
Sprite 2's script:
[blocks]
<when I receive[ move under
<glide( 1 )secs to x sad  ? )y sad  ?
[/blocks]

Last edited by WeirdF (2009-08-14 03:40:54)


http://i.cr3ation.co.uk/dl/s1/gif/847032b8a331def77529b6a0384db1fe_handfingers.gif

Offline

 

#4 2009-08-20 18:55:53

mrgrantb
Scratcher
Registered: 2009-08-20
Posts: 1

Re: Moving 2 sprites when 1 is clicked, any help would be appreciated.

Like weirdF says, add a broadcast to Sprite 1 which - when received by Sprite 2 - makes sprite 2 move.  Add "if touching sprite 2 ..." to sprite 1 so that sprite 1 moves when sprite 2 moves to it.
smile

Offline

 

#5 2009-08-21 11:53:09

Mawile
Scratcher
Registered: 2009-04-21
Posts: 100+

Re: Moving 2 sprites when 1 is clicked, any help would be appreciated.

make a variable that records sprite 1's x position, and another for the y position Then make it so when sprite one is clicked, sprite goes:
<glide( 1 )secs to x sad <{ Sprite 1 X }>  )y sad  <{ Sprite 1 Y }>

Last edited by Mawile (2009-08-21 11:53:21)


I'm Registeel, Sadly i forgot my password :'(
http://img197.imageshack.us/img197/9941/cooking.jpghttp://img194.imageshack.us/img194/9608/telescopeweegee.jpg

Offline

 

#6 2009-08-24 11:29:58

Mawile
Scratcher
Registered: 2009-04-21
Posts: 100+

Re: Moving 2 sprites when 1 is clicked, any help would be appreciated.

And wouldn't this be better off in all about scratch?


I'm Registeel, Sadly i forgot my password :'(
http://img197.imageshack.us/img197/9941/cooking.jpghttp://img194.imageshack.us/img194/9608/telescopeweegee.jpg

Offline

 

#7 2009-08-29 19:59:18

joeyman
Scratcher
Registered: 2008-03-28
Posts: 1000+

Re: Moving 2 sprites when 1 is clicked, any help would be appreciated.

First, you should make a "When Clicked" block in Sprite 1. Then make it "broadcast" a message to sprite 2, telling sprite 2 to go under sprite 1. You could make it go to that position, OR is Sprite 1 is moving, you can make Sprite 2 go to "10 pixels below" Sprite 1.


Joeyman: On Scratch since March 28, 2008.
Over 142 projects! (And recently a Brony, and PROUD of it!)

Offline

 
  • Index
  •  » New Scratchers
  •  » Moving 2 sprites when 1 is clicked, any help would be appreciated.

Board footer