CadetEditor/CadetEngine-as

Transform2D branch: Nesting transforms in the editor causes a jump

Closed this issue · 2 comments

In the editor, create 2 rectangle components.
Now nest the second within the first.
The visual position of the second rectangle jumps as the transform coords are interpreted to be local to the parent transform. I expected the position of the object on screen to remain the same when performing this change, and for the coords of the nested transform to be updated to reflect this.
Can this be changed to prioritise visual consistency, without causing other drawbacks?

It does, but it has to be fixed in the editor. I could, of course, implement recalculating coords from global to parent space when added to parent, but this would made using Transform2D in the code almost impossible, i.e. it would be impossible to create an object, set its transform (x, y) and then add it to parent, because it would be translated.

Editor should modify Transform2D according to context while object containing it is being added to or removed from parent. This can be done using Transform2D globalMatrix property.

I thought you'd say that, sounds sensible. I'll create a transform2D branch for the editor and have a fiddle...