Gamua / Starling-Framework

The Cross Platform Game Engine
http://www.starling-framework.org
Other
2.82k stars 821 forks source link

Calling alignPivot() on Sprite3D does not trigger transformationMatrix revalidation #966

Closed b005t3r closed 7 years ago

b005t3r commented 7 years ago

Consider this:

var quad:Quad = new Quad(300, 300);
var sprite3D:Sprite3D = new Sprite3D();
sprite3D.addChild(quad);
sprite3D.alignPivot();
parent.addChild(sprite3D);

The expected result is that sprite3D should be draw with its center anchored at parent's top-left corner.

The actual result is that it's top-left corner is anchored at the parent's top-left corner, as if the pivot hasn't been changed at all.

This is caused due to _transformationChanged not being set to true on alignPivot() call in Sprite3D (this method is not overridden).

PrimaryFeather commented 7 years ago

Thanks! That one was an easy fix. :smile:

b005t3r commented 7 years ago

Thanks, Daniel!

BTW, this particular issue is somehow connected to #954 - if setOrientationChanged() was changed to protected, _transformationChanged should be set inside it (overridden in Sprite3D) and you wouldn't need to override all of the other methods you did just to set _transformationChanged (you'd only need to do it once inside set transformationMatrix).

PS. I'm not complaining, just trying to prove that it really makes sense to do what I proposed in #954 😄