We’ve used Animate to author animations and Generate Texture Atlas to export them for Starling & have had lots of positioning problems with nested clips.
I might have narrowed the problem (or at least one problem) down to how Generate Texture Atlas is calculating “Position” in the Animation.json file for nested symbols. Particularly when the parent symbol has a scale other than 1. Can anyone tell me if this is a known bug in Animate?
The attachment contains an FLA and files output through Generate Texture Atlas with a simple example of the problem in the symbol named Export.
Structure of Export inside Animate:
"Export" ← Symbol exported with Generate Texture Atlas
↳ “A" ← Scale = 50%; (Position is 0.0);
↳ "image" ← Position = 200,0; (Scale = 100%);
↳ ”image.png" ← Position = 400,0; (Scale = 100%; Width and Height = 200px);
image.png should appear 300px to the right of 0,0 — (Position: (200 + 400) * 0.5 = 300) — and that’s what Animate/SWF shows. But the exported Texture Atlas in Starling shows image.png at 225px.
The exported JSON file shows “A” with an X position of (about) 450px — and Matrix3D shows an x and y scale of 0.5.— so that seems like where the 225 is coming from.
So the 450 Position X value seems suspect. After looking at this and several other examples (most with more complex setups), it appears Generate Texture Atlas is taking the offset in the child symbol (but not the offset of the bitmap itself), multiplying that by the scale TWICE and then adding it to the unscaled bitmap offset.
Position X = (Total offsets in children * Scale * Scale) + Bitmap offset;
or: ( (200 * 0.5 * 0.5) + 400 ) * 0.5 = 225;
If you remove the scale from "A" Position X reports 600 and all is good.
Again, I tried this with several setups and this formula consistently predicted the positioning in the exported JSON file. If there are more symbols in the hierarchy (between top parent and bitmap) each with their own offset, each offset is multiplied twice by the parent's scale, but the bitmap offset is never scaled (for positionX in the JSON).
I have a suspicion that this may also be affecting Transformation Points but haven’t had time to check.
https://www.dropbox.com/s/jrradcw3sgmbdwj/JSONtransformBugSamples.zip?dl=0