Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dragging sprites in Scratch

How do I drag sprites during execution in Scratch?

like image 816
ruchir patwa Avatar asked Apr 24 '26 11:04

ruchir patwa


1 Answers

This is covered on the Scratch Wiki.

boisvert's answer is technically correct, however, his script will always drag the sprite from it's center. Using a slightly more advanced script will drag from the spot it was picked up, more like the padlock:

when green flag clicked
forever
  if <<mouse down?> and <touching [mouse-pointer v]?>>
    repeat until <not <mouse down?>>
      set [offset x v] to ((x position) - (mouse x))
      set [offset y v] to ((y position) - (mouse y))
      go to x: ((mouse x) + (offset x)) y: ((mouse y) + (offset y))
    end
  else
    wait until <not <mouse down?>>
  end

(The wiki link above has this is visual blocks format.)

like image 56
Scimonster Avatar answered Apr 30 '26 21:04

Scimonster



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!