Blocks for Dragging Sprites
-
Prerequisite
Description
To work with the dragging event, you need these 3 Hat blocks in the “Events” category: “When dragging starts”, “When being dragged” and “When dragging stops”.
Full Screen Drag Mode
By default, you can not drag a sprite in the full screen mode.
To make a sprite draggable in the full screen stage, you have to use the “Set drag mode” block from the sensing category, and select “draggable” from the drop down menu.
Here is how you can do it:
“When Dragging Starts” Block
This block will be triggered the moment you start dragging a sprite. For example, we can change the dog sprite’s costume to close its eyes when we start dragging it.
“When Being Dragged” Block
This block will run repeatedly while you drag a sprite on the stage (full screen mode only).
“When Dragging Stops” Block
This block runs when you stop dragging a sprite and release your mouse. In this example below, we make the dog go back to the center of stage whenever we stop dragging it.