0
votes

I have a problem regarding movement of Box2D sprite body. The problem is when I press the left button, my sprite moves left and when I release the button, my sprite will stop.

I know the logic of movement, but do not know how to create the left button for continuous movement.

1

1 Answers

1
votes

When u press the button set some Boolean variable to true and then in update/tick method just do this :

If(boolVariable == true) {

  sprite.position = ccp(sprite.position.x - 0.5 , sprite.position.y);

}

This should move your sprite to left in continuation.