Except for one problem with OOP: Because chipmunk is written in plain C, I'm not able to bind the velocity_func to a non-static member method (C++). I've tried several workarounds so far but hadn't any luck with this.
I understand that pointer to member methods are a different size, then pointer to functions. Had anyone the same problem and found a Solution? Some code:
Code: Select all
class Player{
public:
Player();
~Player();
void playerUpdateVelocity(cpBody *body, cpVect gravity, cpFloat damping, cpFloat dt);
protected:
private:
cpBody *playerBody;
};
Player::Player(){
playerBody = cpBodyNew(1.0f, INFINITY);
playerBody->velocity_func = playerUpdateVelocity;
}
void Player::playerUpdateVelocity(cpBody *body, cpVect gravity, cpFloat damping, cpFloat dt){
// do something
}
Thanks for any help!