sprite - How to set position of a dynamic body in andengine? -


i'm developing game using box2d. have move ball according accelerometer. have created body n connected ballsprite it. i'm moving body using setlinearvelocity(). once ball reaches boundaries of screen,i want stop movement of ball @ edge of screen. how do this?

public void onaccelerationchanged(accelerationdata arg0) {     ballbody.setlinearvelocity(arg0.getx(), 0);    } 

you can set body velocity 0 when reach boundaries.place condition in update handler , place below statement

 body.setlinearvelocity(0, 0); 

(or) can make the body type static

  body.settype(bodytype.static); 

Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -