I want to make a doodle jump like, I create two body one for the player and one for the platform, but instead of bouncing on the Platform Body, the player can jump on all the line at the Y coords of the body. Don't know why.
private void creerPlateformes(int n)
{
int pX[] = new int[n];
int pY[] = new int[n];
pX[0] = CAMERA_WIDTH/ 2-60;
pY[0] = 780;
for (int i=0;i<n;i++)
{
if (i!=0)
{
final Random r = new Random();
pX[i] = r.nextInt(464-16)+16;
pY[i] = pY[i-1]-r.nextInt(200-100)+100;
}
plateforme[i] = new Sprite(pX[i], pY[i], mPlateformeTextureRegion, getVertexBufferObjectManager());
plateforme[i].setScale(1);
plateforme[i].setUserData("plateforme");
final FixtureDef PLATEFORME_FIX = PhysicsFactory.createFixtureDef(0.0f, 0.0f, 0.0f);
plateformeBody[i] = PhysicsFactory.createBoxBody(physicsWorld, plateforme[i], BodyType.StaticBody, PLATEFORME_FIX);
plateformeBody[i].setUserData("plateforme");
scene.attachChild(plateforme[i]);
}
}
Tell me if you need more code, but I think the problem may be there.
as you told in the comments, it's not, that the players body was moved, instead you moved the sprite alone ;-)
moving the player by the sensor event, you could use something like
playerBody.setLinearVelocity (float vX, float vY)
with the x value depending on your sensor, the y value should be something like your jump-speed imho
then you don't need to move the sprite anymore, since it will be moved with the bodies moving