Pages: 1
Topic closed
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
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 ? )y ?
[/blocks]
Sprite 2's script:
[blocks]
<when I receive[ move under
<glide( 1 )secs to x ? )y ?
[/blocks]
Last edited by WeirdF (2009-08-14 03:40:54)
Offline
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.
Offline
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 <{ Sprite 1 X }> )y <{ Sprite 1 Y }>
Last edited by Mawile (2009-08-21 11:53:21)
Offline
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.
Offline
Topic closed
Pages: 1