使用Chimpunk身体位置驱动Cocos2D Parallax

发布于 2024-09-10 08:18:05 字数 255 浏览 3 评论 0原文

我在 Cocos2D 中使用 Chipmunk 和 SpaceManager。我有一个随着脉冲移动的身体,我希望能够使用该身体位置来驱动 Cocos2D 中的视差节点。

因此,当物体“a”向左移动时,视差也会随之移动,但会产生较小的时间偏移或弹性效应。如果您了解 AS3 和 Flash,您可以将其视为使用影片剪辑的 x 和 y 位置来驱动不断更新的补间,并具有缓出效果。这就是我想要实现的目标,昨晚一夜未眠试图解决这个问题后,我决定向更有经验的人请教:)

谢谢。

I'm using Chipmunk with SpaceManager inside of Cocos2D. I have a body which is moving around with impulses, I'd like to be able to use that bodies location to drive a parallax node in Cocos2D.

So, when body 'a' moves to the left, the parallax follows but with a small time offset, or elastic effect. If you know AS3 and Flash, you can think of this as using a movieclip's x and y location to drive a constantly updating tween with an ease out effect. This is what I'd like to achieve, and after no sleep trying to work it out last night I've decided to ask you much more experienced people :)

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

青衫负雪 2024-09-17 08:18:05

您可以将附加主体与视差节点相关联,并使用合适的关节或一组关节将其附加到主体a。很难从问题中看出您正在寻找什么确切的行为,但至少滑动、凹槽或阻尼弹簧约束之一应该可以解决问题。

You could associate an additional body with the parallax node, and attach it to body a with a suitable joint or set of joints. It is difficult to tell from the question what exact behaviour you are looking for, but at least one of slide, groove or damped-spring constraint should do the trick.

看轻我的陪伴 2024-09-17 08:18:05

我解决了这个问题,供将来参考,以防其他人需要它,您可以使用:

[voidNode setPosition:(yourShape.position)];

I worked this out, for future ref in case others need it you use:

[voidNode setPosition:(yourShape.position)];

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