I am having problems with an ice-hockey game. I have boundaries for players to collide with to keep them within an arena, but they frequently break free/escape the boundaries. I have posted before but haven't received any feedback about this issue.
This is an easy.
if (getX()>= getWorld().getWidth()-){
setLocation(getX()-,getY());
}
The best way to do this is to have two variables for x and y movement. Example: xmove=0; ymove=0;. Then you should at the end of the script do setLocation(getX()+xmove,getY()+ymove);. For the left you would do if (getX()<= getWorld().getWidth()-).
For Y, you must do if (getY() >= getWorld().getHeight()-)
You get the Idea now, right? Not difficult at all. If you do this, you should have no problems with anyone going past the boundary.