Click action impacts objects beneath

I am new, coming from Fusion and Flash. I am creating an education app, like a puzzle pieces that can be dragged and rotated. The problem is, when right clicking to rotate a piece, any piece underneath or lower z order, also rotates. It seems that a click action affects any object under the cursor regardless of layer, z order, or visibility. Is this correct? My less than ideal workaround has been to draw a small circle on the sprites and changing the collision zone to just the little circle. So to drag and rotate objects requires putting the cursor in the circle. This works most of the time, but occasionally even the hotspots i created within the object will line up and a right click will rotate the object underneath.

I have seen apps with objects that can be dragged and rotated, even when objects end up stacked on each other. But i cant seem to replicate that behavior with this app. Any ideas? I am new and i am sure i am missing sonething!

Add community extension Object Picking Tools, then you can specify: pick object with highest zorder as part of your condition.

Draggable behavior seems to pick the highest zorder, but you’re letting go of the object to rotate it, otherwise I would just suggest adding object is being dragged to your condition to rotate.

You could add a condition to rotate it only if the item is visible but that only works if you mark the puzzle pieces underneath as hidden. If something is visible but the user can’t see it because it’s off screen, on a hidden layer or under something it wouldnt work.

2 Likes

When you click on overlapping objects, all the objects get picked. You can use the “Object Picking Tools” extension to get the highest Zorder or use a for each object and pick the highest value. Use as much or as little from my example as you like.

Here’s an example. You can drag with the left mouse and rotate 90 degrees with the right.

Source. I tried to add comments to help.
doug13579/Gdevelop-puzzle-drag-rotate (github.com)

1 Like