Collision with dragged imagesprite

I'm sorry for my bad english! I need to create an imagesprite that I can drag, and when it collides with another imagesprites, it must not pass through it, as if it were a block. Can anyone tell me how can I do it? Thanks!!

Welcome Andrea.

I do not believe you can use the Dragged event that way.

The Dragged event only responds to startX ,startY ,prevX ,prevY ,currentX ,currentY ), not to the intermediate coordinates which the Sprite 'passes through'; consequently there is not a way to determine a 'collision' point.

What you can do to create a collision is discussed in Creating Animated Apps by using MoveTo blocks etc.

Perhaps the code shown in Figure 5-14 in Ladybug Chase is what you want to do?

There might be a way to do this in the drag event, if it had access to a global list of the other Sprites' components, which could be used dynamically to predict crashes using X,Y, Height and Width of all the objects and the object being dragged.

If a crash has happened or is imminent, restrict adjustments to the dragged object's X,Y to only allow it to back away from the nearest object.

Hello Andrea

Are the other Sprites stationary (never move or rotate)? I ask because currently, if you drag a sprite so it collides with another, they become attached to each other (a known bug, I don't know when it will be fixed). If the other sprites are stationary, they can be disabled and the proximity of the dragged sprite can be calculated against their x,y positions plus width and height (stored in a Block List).