0
나는 우주선과 게임을 만들었지 만 움직이는 데 문제가있다. 스크립트입니다.자바 게임 회전 이미지와 축
public class spaceship {
private final local_client local_client;
private final int startX;
private final int startY;
private final int startR;
private double x,y,r;
public static double rotation;
public static double velo;
public static AffineTransform at;
public spaceship(local_client local_client,int startX,int startY,int startR) {
this.local_client = local_client;
this.startX = startX;
this.startY = startY;
this.startR = startR;
x=200;
y=200;
r=90;
}
public void drawImage(Graphics2D g2d) {
g2d.drawImage(local_client.spaceship_img,200,200, local_client.game);
at = g2d.getTransform();
at.translate(x , y);
at.rotate(Math.toRadians(r));
at.translate(-(local_client.spaceship_img.getWidth()/2),-(local_client.spaceship_img.getHeight()/2));
System.out.println(at.getTranslateX() + " - " + at.getTranslateY());
g2d.setTransform(at);
g2d.drawImage(local_client.spaceship_img,0,0, local_client.game);
}
그래서 내가 이미지를 회전 할 수있는이 스크립트 (화면 참조) http://gyazo.com/c982b17afbba8cdc65e7786bd1cbea47
내 문제를 내가 정상 축 X 또는 Y 이동 (화면) 증가하는 경우 : http://gyazo.com/1fb2efb5aff9e95c56e7dddb6a30df4a 및 하지
안녕하세요, 크기는 얼마입니까?이 방법을 호출해야합니까? –
@terzi_matte 차량이 자동차라고 가정 해 봅시다. 가스 페달을 밟을 때 즉시 100kmph로 가나, 점차 빨라 100kmph까지 올라갑니다. 크기를 추가하면 배가 얼마나 빨리 진행되는지 확인할 수 있습니다. 따라서 게임에서 100의 크기는 우주선이 초당 100 픽셀로 비행하고 있음을 의미합니다. 10의 크기는 초당 10px를 의미합니다. – Compass
네, 대단히 감사합니다, 1 시간 후 이해했지만 고마워요. 나는 당신이 코사인과 죄를 뒤집어 썼다고 생각합니다. :) –