Closed linuxerwang closed 4 years ago
Hi, thanks for the question. I think the reason why height and width was not added, is that those properties are quite complicated and the depend on many other properties like scaleX, scaleY, skewX, skewY and in the end also on the rotation. Therefore it's easier (any maybe bettter) to scale one of those properties.
But you can also create your custom class derived from Animatable to implement something that changes the width and height over time. Or you can use the Translation (which is an Animtable) to scale those properties. It's only a little bit more code to write compared to the Tween class.
Gotcha. Thanks for the explanation!
Hi,
I want to display a tween of a rectangle moving and changing size, but TweenPropertyAccessor2D has not w, h property so this is not possible:
var rect = Shape(); rect.graphics.rect(0, 0, 20, 200); rect.x = 100; rect.y = 200; rect.graphics.strokeColor(Color.Red); stage.addChild(mask);
var tween = Tween(rect, 2.0, Transition.linear) ..animate.x.to(200.0) ..animate.y.to(400.0) ..animate.w.to(80.0) ..animate.h.to(100.0); tween.onUpdate = () { rect.graphics.clear(); rect.graphics.rect(0, 0, animate.w, animate.h); rect.graphics.strokeColor(Color.Red); }; stage.juggler.add(tween);
Should w, h properties be added to TweenPropertyAccessor2D?
Thanks!