开发者

Use Chipmunk body location to drive Cocos2D Parallax

开发者 https://www.devze.com 2023-01-08 06:57 出处:网络
I\'m using Chipmunk with SpaceManager inside of Cocos2D.I have a body which is moving around with impulse开发者_运维技巧s, I\'d like to be able to use that bodies location to drive a parallax node in

I'm using Chipmunk with SpaceManager inside of Cocos2D. I have a body which is moving around with impulse开发者_运维技巧s, 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.


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.


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

[voidNode setPosition:(yourShape.position)];

0

精彩评论

暂无评论...
验证码 换一张
取 消