Tripleplay Animator 添加图层
我有以下(伪)代码,
root = _iface.createRoot(...)
Label l = new Label("hello world");
anim = Animator.create();
anim.delay(1500).then().add(root.layer, l.layer);
anim.delay(1000).then().action(new Runnable() {
public void run() {
// root.add(l);
System.out.println("it works");
}
});
it work's行打印正常,所以我假设我正在正确更新动画,但标签从未添加到场景中!
如果我取消注释 Runnable
中的 root.add(l)
,它会按预期工作(标签在 1 秒后添加),但不会添加 < code>anim.delay(1500).then().add(root.layer, l.layer);
知道我做错了什么吗?
I have the following (pseudo) code
root = _iface.createRoot(...)
Label l = new Label("hello world");
anim = Animator.create();
anim.delay(1500).then().add(root.layer, l.layer);
anim.delay(1000).then().action(new Runnable() {
public void run() {
// root.add(l);
System.out.println("it works");
}
});
the it work's line gets printed ok, so I assume I'm updating the animation right, but the label is never added to the scene!
If I uncomment the root.add(l)
inside the Runnable
it works as expected (the label is added after 1 second), but it doesn't get added with anim.delay(1500).then().add(root.layer, l.layer);
any idea whay I'm doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不能只是将 TPUI
Widget
层添加到另一个层并期望Widget
正确渲染。必须通过 Group.add 将小部件添加到其父级。您使用的动画代码更多地是为原始 PlayN 层而不是 UI 元素的动画而设计的。 UI 元素通常使用
LayoutManager
进行布局,它控制层的位置。如果您尝试直接对图层进行动画处理,您可能会混淆布局管理器,并且通常会弄乱所有内容。也就是说,对界面的
Root
进行动画处理是非常安全的,因为它将整个 UI 锚定到 PlayN 场景图中。如果您确实想尝试上面所做的事情,请不要使用
Animator.add
use:(就像上面一样),它将正确地将
Label
添加到 < code>Root,并触发Label
的验证和渲染。You can't just add the layer of a TPUI
Widget
to another layer and expect theWidget
to render properly. A widget must be added to its parent viaGroup.add
.The animation code you are using is more designed for animating raw PlayN layer's than UI elements. UI elements are generally laid out using a
LayoutManager
which controls where the layer is positioned. If you tried to animate the layer directly, you would confuse the layout manager and generally mess everything up.That said, it's pretty safe to animate the
Root
of the interface, because that anchors a whole UI into the PlayN scene graph.If you really want to try what you're doing above, don't use
Animator.add
use:(like you have above) which properly adds the
Label
to theRoot
, and triggers validation and rendering of theLabel
.