使用Chimpunk身体位置驱动Cocos2D Parallax
我在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以将附加主体与视差节点相关联,并使用合适的关节或一组关节将其附加到主体
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.我解决了这个问题,供将来参考,以防其他人需要它,您可以使用:
[voidNode setPosition:(yourShape.position)];
I worked this out, for future ref in case others need it you use:
[voidNode setPosition:(yourShape.position)];