이 질문은 다른 것들과 비슷하지만 사각형 경계의 게임 개체가있는 것 같습니다. 어느 위치로 움직입니다. 중간에있는 항목과 교차하는 경우 줄을 따라 어떻게 확인할 수 있습니까?거리가 충돌했을 때 사각형이 한 위치에서 다른 위치로 이동할 때 게임 충돌 검사
극단적 인 시나리오. [x = 2, x = 1, width = 1, height = 1] A는 [x = 4, y = 1, width = 1, height = 1]로 이동합니다. 사각형 B가 [3,1,0.5,0.5]에있는 곳에 놓치면 놓치게됩니다.
스칼라 및 교차 제품에 대해 읽었지만 올바르게 읽으면 단일 행입니다. 이것은 낮은 프레임 속도로 느린 장치에서 안드로이드 게임 개발로 인한 것입니다. 나는 그것을 대상으로 떨어 뜨리고있다. 아래의 코드를 사용하여 intersects를 확인합니다.
public boolean testIntersection(GameVector lowerLeftMain, float mainWidth, float mainHeight, GameVector lowerLeftCollider,
float colliderWidth, float colliderHeight){
boolean intersect = false;
if(lowerLeftMain.x < lowerLeftCollider.x + colliderWidth+0.08f && //checks left collision
lowerLeftMain.x + mainWidth > lowerLeftCollider.x-0.08f && //checks right collision
lowerLeftMain.y < lowerLeftCollider.y + colliderHeight+0.08f &&//checks top collision
lowerLeftMain.y + mainHeight > lowerLeftCollider.y-0.08f)//checks bottom collision
intersect = true;
return intersect;
}
제가 직사각형을 포기하고 레이 캐스트 라인 충돌 스타일에 집중한다면 누군가 올바른 방향으로 나를 가리킬 수 있습니까?
미리 감사드립니다.
http://stackoverflow.com/questions/9438690/whats-the-best-way-to-do-collision-detection, http://gamedev.stackexchange.com/questions/24434/polygon- 충돌 감지 안드로이드, – user2864740