안드로이드 게임 개발 정보
(글 수 223)
지금 간단한게임을만들고있는데
엔진사용 x 안드로이드 canvas 사용
화면에 터치를하면 가운데서 터치한방향으로 미사일이 날라가는것을구현중인데
터치좌표값을구해도 그방향구할방법이 아무리생각해도 생각이안나는데 어떤식으로 만들면될까요?
2012.07.26 23:40:11
private double angles(float touchX, float touchY, float centerX, float centerY){
double Rad = 0;
int Degree = 0;
if(touchX - centerX > 0) {
Rad = Math.atan((touchY-centerY)/(touchX-centerX)) + Math.PI/2;
} else if(touchX - centerX < 0){
Rad = Math.atan((touchY-centerY)/(touchX-centerX)) + Math.PI/2*3;
}
Degree = (int) Math.toDegrees(Rad);
return Degree;
}
이걸로해결봣네요 ㅎ
다들댓글감사합니다
현재 캐릭터 위치 좌표와 터치한 좌표를 가지고 쿵덕쿵덕 하면 방향이 나오지 않을까요??
http://hapina.tistory.com/25
http://snowflower.tistory.com/203