I am trying to make a player jump in my game when it touches a platform, but at the same time it should be controlled by the Accelerometer to move left and right. So, I was thinking about applying linear velocity on the Y axis in the contact listener to make it jump, while applying linear velocity on the X axis when the Accelerometer changes its value.
The problem is when I use the setLinearVelocity method, it sets the values for the Velocity on both axis. As a result, the player doesn't jump because the accelerometer changes the velocity value on the Y axis.
Does any one have an idea how to do this?
b2Vec2 v = body->GetLinearVelocity();
v.x = ...;
body->SetLinearVelocity( v );