안녕 처리 중 개체와 충돌하려면 글 머리 기호를 어떻게 만듭니 까? 글 머리 기호가 실행되고 변환되고 회전 됨 하지만 dist() 함수를 사용하려고 할 때마다 항상 벡터의 위치가 0이됩니다. 글 머리 기호를 사용하여 개체와 충돌 시키려면 올바른 벡터 위치를 얻는 방법 거리를 만들고 다른 물체를 사라지게 만드시겠습니까?글 머리 기호 상호 작용 처리
여기에 코드
void move(){
passed = passed + time;
if (passed > bulletLife) {
alive = false;
}
forward.x = sin(theta);
forward.y = -cos(theta);
float speed = 15.0f;
velocity = PVector.mult(forward, speed);
side.add(forward);
void display(){
pushMatrix();
translate(side.x, side.y);
rotate(theta);
stroke(255);
ellipse(side.x, side.y, 30, 30);
popMatrix();
에게
감사 translate()
좌표계 이동하기 때문에 당신은 dist()
에서 0을 받고있어
이 코드에서 dist() 함수를 어디에서 사용하고 있습니까? [MCVE] (http://stackoverflow.com/help/mcve)를 게시 할 수 있습니까? –
여기에 어떻게 거리를 계산 PVector kool2 = coordinates(); float d = kool2.dist (위치)/10; } // end display() PVector 좌표() { PVector kool; kool = 새로운 PVector (side.x + cos (theta) * x2, side.y + sin (theta) * y2); 돌아 오는 kool; } // end coordinates – UserMan