I'm trying to make a game for Android, I have a problem when dealing with multiple resolutions, this is a example of my gameview: http://oi42.tinypic.com/vh6ir6.jpg.
In the small area, there are several pieces of information, while the largest area is my play area. My purpose is to prevent the image (bitmap) from going beyond the edges of the playing area. This is partially working, but it only works with 800x432 resolution (the resolution of my tablet xD )
This is my code:
case MotionEvent.ACTION_MOVE:
//left edge
if (deltaX <= 90 && deltaY <= 400 && deltaY >28){
Static_PositionX = 52;
Static_PositionY = (int)deltaY-35;
Drag = false;
}
//down edge
else if (deltaY >= 380 && deltaX > 90 && deltaX <770) {
Static_PositionX = (int)deltaX-42;
Static_PositionY = 360;
Drag = false;
//right edge
}else if((deltaY <= 390 && deltaY > 20) && deltaX > 770){
Static_PositionX =723;
Static_PositionY = (int)deltaY-35;
Drag = false;
}
// up edge
else if ((deltaX >= 90 && deltaX < 770) && deltaY <= 35 ){
Static_PositionX =(int)deltaX-42;
Static_PositionY = 0;
Drag = false;
}
where deltaX and deltaY are my image coordinates and Static_PositionX/Static_PositionY are a random start position
deltaX=event.getX();
deltaY=event.getY();