Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Dragging
- Charizard744
-
8 posts
Dragging
How would you make for example, a sprite move by dragging WITHOUT putting your cursor on the sprite at all.
- PaSc_Clan
-
64 posts
Dragging
Is this what you're looking for?
when green flag clicked
forever
if <mouse down?> then
set [dx v] to ((x position) - (mouse x))
set [dy v] to ((y position) - (mouse y))
repeat until <not <mouse down?>>
go to x: ((mouse x) + (dx)) y: ((mouse y) + (dy))
end
end
end
- Charizard744
-
8 posts
Dragging
Like I mean you drag on the screen and the sprite moves without touching the sprite. do you mean making a sprite follow the mouse?
- Charizard744
-
8 posts
Dragging
So like you drag your finger/cursor on the screen and it moves a sprite even tough you're not touching the sprite. what do you mean?
- PaSc_Clan
-
64 posts
Dragging
So like you drag your finger/cursor on the screen and it moves a sprite even tough you're not touching the sprite. what do you mean?
I provided code that does just that.
Is this what you're looking for?when green flag clicked
forever
if <mouse down?> then
set [dx v] to ((x position) - (mouse x))
set [dy v] to ((y position) - (mouse y))
repeat until <not <mouse down?>>
go to x: ((mouse x) + (dx)) y: ((mouse y) + (dy))
end
end
end
- Charizard744
-
8 posts
Dragging
Yes, thank you! Is this what you're looking for?when green flag clicked
forever
if <mouse down?> then
set [dx v] to ((x position) - (mouse x))
set [dy v] to ((y position) - (mouse y))
repeat until <not <mouse down?>>
go to x: ((mouse x) + (dx)) y: ((mouse y) + (dy))
end
end
end
- Discussion Forums
- » Help with Scripts
-
» Dragging