I want to make a very simple tangram puzzle, where the player has all of the shapes and has to rotate and move them to correctly fit into a larger shape. I know how to make the shapes draggable, but I can’t figure out how to make it so a player can click on each shape and rotate it.
How about creating a rotate handle, similar to what the GDevelop editor has for objects placed on the scene? If an object is clicked on, then move the the rotate handle above the object and and link the two. Then rotate the linked shape when the mouse is moved (and maybe while a mouse button is down?).
Thanks that’s a useful recommendation. I should clarify that I am brand new to GDevelop and while I understand that concept you’ve described, I don’t know how to get an object to rotate at all while a mouse button is down (I could figure out how to create a handle and link it to the object, but how do I get that handle to rotate when the mouse button is down)?
You’ll need to get the angle between the object and handle centres. I think atan2 comes into play here. Then, calculate the angle between the mouse and the object’s centre using the same atan2 calculation, and set the actual angle of the object with the difference.
Give me a few hours (I’m at work atm), and I’ll rustle up some sample events to get you going (if no-one else does it first).
Here’s a solution. When you click on the rotate handle, it gets the difference between tangram’s current rotation angle, and the angle between the tangram piece and the mouse. It then applies that difference to angle between the mouse and the tangram piece as the mouse moves around, setting the tangram piece’s rotation angle.
That’s extremely helpful - I’ll work on it this weekend and see if I can get it to all fit together. Thank you so much!