저는 Libgdx와 box2d를 처음 사용합니다. 나는 호를 그릴 필요가 있었다. 마지막으로 함수를 검색했습니다.libgdx box2d drawarc
public void drawarc (float centerx, float centery,float radius, float anglefrom, float anglediff, int steps)
{
EdgeShape ps = new EdgeShape();
FixtureDef psfd = new FixtureDef();
psfd.shape = ps;
BodyDef psbd = new BodyDef();
psbd.allowSleep = true;
psbd.awake = true;
psbd.position.set(centerx, centery);
psbd.gravityScale = 0;
Vector2[] vertices = new Vector2[steps];
for (int i = 0; i < steps; i++) {
double angle=Math.toRadians(anglefrom+anglediff/steps*i);
Vector2 sc = new Vector2((float)(radius * Math.cos(angle)),
(float)(radius * Math.sin(angle)));
vertices[i] = sc;
}
Body psd = world.createBody(psbd);
for (int i = 1; i < steps; i++) {
ps.set(vertices[i-1], vertices[i]);
psd.createFixture(psfd);
}
}
제대로 작동하지만 올바른 방법인지 확실하지 않습니다. 너는 그것의 능률적이고 정확한 방법다는 것을 검사하고 저에게 말 하십시요 주시겠습니까?
감사합니다.
그래픽 출력의 멋진 특성은 "모양이 맞다면"입니다. 축하해. 즉, 이것은 실제로 Stack Overflow에 적합한 질문이 아닙니다 (http://stackoverflow.com/faq#dontask 참조). 코드 검토 스택 교환 (http://codereview.stackexchange.com/)에서 더 많은 행운을 누릴 수 있습니다. –