Tripleplay Animator 添加图层

发布于 2025-01-03 17:51:31 字数 576 浏览 2 评论 0原文

我有以下(伪)代码,

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

飘过的浮云 2025-01-10 17:51:31

您不能只是将 TPUI Widget 层添加到另一个层并期望 Widget 正确渲染。必须通过 Group.add 将小部件添加到其父级。

您使用的动画代码更多地是为原始 PlayN 层而不是 UI 元素的动画而设计的。 UI 元素通常使用 LayoutManager 进行布局,它控制层的位置。如果您尝试直接对图层进行动画处理,您可能会混淆布局管理器,并且通常会弄乱所有内容。

也就是说,对界面的 Root 进行动画处理是非常安全的,因为它将整个 UI 锚定到 PlayN 场景图中。

如果您确实想尝试上面所做的事情,请不要使用 Animator.add use:

action(new Runnable() {
  root.add(l);
});

(就像上面一样),它将正确地将 Label 添加到 < code>Root,并触发 Label 的验证和渲染。

You can't just add the layer of a TPUI Widget to another layer and expect the Widget to render properly. A widget must be added to its parent via Group.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:

action(new Runnable() {
  root.add(l);
});

(like you have above) which properly adds the Label to the Root, and triggers validation and rendering of the Label.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文