I'm assuming that the physics engine for cocos2d-x already has this ability and you will just need to dig a little bit more.
Otherwise, I'm also thinking of trying to implement something similar myself for a mockup game I'm trying to create. Right now (not sure whether it's a good idea or not) I'm thinking of adding a new property that determines what kind of collision can apply to a certain object. And depending on the velocity/accel (whatever your movement indicator is defined as) will be the check for this collision.
You can also check this out:
It has some in-depth explanation of how to implement a kind of collision detection and it also includes your question.
From my understanding... the key conditions for a one-way platform are:
- if the velocity of the object is positive, ignore the collision.
- if the base of the object's position is less than the position of the top of the platform, ignore the collision.
You will need to determine what kind of conditions are required for a one-way platform.
On another note, I went and took a quick look into Chipmunk and it looks like one-way platform is very trivial.
Here's a code snippet from the Demo Chipmunk provides:
// Add our one way segment
shape = cpSpaceAddShape(space, cpSegmentShapeNew(staticBody, cpv(-160,-100), cpv(160,-100), 10.0f));
// We'll use the data pointer for the OneWayPlatform struct
platformInstance.n = cpv(0, 1); // let objects pass upwards
//at the very end
//preSolve -> looks like checking the direction of the object with a normal vector
//and fails the collision if the direction of the normal is negative
cpSpaceAddCollisionHandler(space, 1, 2, NULL, preSolve, NULL, NULL, NULL);
The file is called OneWay.c