独立于父母为孩子制作动画
我们正在创建一个系统,其中显示单元中的元素是通过 xml 定义的。这也意味着整个系统本质上是动态的。因此无法知道某个元素是否具有与其关联的补间。
<element id="name" type="txt" top="0" txt="Black look down" left="0" width="145" height="35"......>
<transitions>
<navIn>
<tween type="default" orientation="horizontal" direction="1" time=".4" delay=".2" stagger="0" ease="Quint.easeOut" />
</navIn>
<navOut>
<tween type="default" orientation="vertical" direction="1" time=".4" delay="0" stagger="0" ease="Quint.easeIn" />
</navOut>
</transitions>
</element>
请注意,它周围还有其他元素,并且每个元素不需要有过渡。
我们可以看到这个元素是一个文本元素。让我们考虑(为了简单起见)该文本元素位于框元素内。该框元素内部可以包含其他元素,例如文本(超过 1 个)。该框可能总是有一个与之相关的转换。现在,如果这个文本元素也有一个过渡,它应该独立于框过渡工作。关于如何实现这一目标有什么想法吗?
We are creating a system where elements in a display unit are defined through xml. This also means that the whole system is dynamic in nature. So there is no way of knowing whether an element will have a tween associated with it or not.
<element id="name" type="txt" top="0" txt="Black look down" left="0" width="145" height="35"......>
<transitions>
<navIn>
<tween type="default" orientation="horizontal" direction="1" time=".4" delay=".2" stagger="0" ease="Quint.easeOut" />
</navIn>
<navOut>
<tween type="default" orientation="vertical" direction="1" time=".4" delay="0" stagger="0" ease="Quint.easeIn" />
</navOut>
</transitions>
</element>
Note that there are other elements around it and also that each element need not have a transition.
We can see that this element is a text element. Lets consider ( for the sake of simplicity ) that this text element is inside a box element. This box element can have other elements inside it like the text ( more than 1 ). The box will probably always have a transition associated with it. Now if this text element also has a transition it should work independently of the box transitions. Any ideas on how this can be achieved?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我可以看到你想让一个孩子属于父母但不接受它的几何变换的原因(分层、可见性、mouseChildren 等)。
这取决于您正在寻找的效果,但是您可以通过将父级变换矩阵的逆应用到容器(例如,容器)来反转父级仿射变换(几何 - 又名缩放/旋转/平移)的效果之间:
在这个示例中,我启动了父容器(红点)正在移动/旋转/缩放,而子容器(蓝点)保持静态,因为我在两者之间创建了一个容器
使用 Matrix.invert 可以轻松反转父变换的效果(注意:在每一帧上执行计算)。您可以在没有容器的情况下完成此操作,但是您需要注意如何对孩子进行补间。
您需要根据您的要求对其进行优化,但我只是表明这是可能的,即使不容易。 =)
查看它实际操作。
I could see reasons (layering, visibility, mouseChildren, etc) you'd want to have a child belong to a parent but not receive it's geometric transformations.
It depends on the effect you're looking for exactly, but you can reverse the effects of the parent's affine transform (geometry - aka scale/rotate/translate) by applying the inverse of the parents' transform matrix, for example, to a container in between:
In this example I whipped up, the parent container (red dot) is being moved/rotated/scaled around while the child (blue dot) remains static because I've created a container in between
that easily reverses the effects of the parent transforms using Matrix.invert (NOTE: calculations performed on every frame). You could do it without a container, but then you'd need to take care how you Tweened the child.
You'll need to optimize it to your requirements, but I'm just showing that it is possible, if not easy. =)
See it in action.
当您调整父级的设置时,它也会应用到子级。 (移动、缩放、旋转)
因此盒子的过渡将始终应用于它的所有子项。但他们肯定可以有自己的转变。 (如果框有“上移”过渡,文本有“左移”过渡,则文本将同时向上和向左移动。)
如果您不希望文本位置受到框位置的影响,则不要将其添加为框的子项。
When you adjust a setting on a parent, it will also be applied to the children. (moving, scaling, rotating)
So the transition of the box will always be applied all it's children. But surely they can have their own transitions. (Fx the box has a "move up" transition, and the text a "move left" transition, then the text will both move up and left.)
If you don't want the text position being affected by the box position, then don't add it as a child of the box.