views:

145

answers:

2

Hello,

I am doing a game with cocos2d and using chipmunk to manage the physics. What I would like to achieve is what pretty much every nintendo game does that your character may jump and rest in a higher floor (collision shape) without causing a collision as long as the velocity is positive, and that once the velocity is negative the collision does happen.

Basically I want to condition the collision between 2 shapes based on the velocity value. Could anyone please point me in the right direction on how to implement this?. Thank you.

-Oscar

A: 

I'd just implement per-pixel collision-detection as normal, but add your additional condition: if the velocity has a upward component, ignore the collision.

John Feminella
+1  A: 

The latest version of Chipmunk has better support for collision events and has a simple demo showing how to implement one way platforms.

slembcke