0
빨간 점이 y 축 아래로 똑바로 내려 오도록하려고합니다. 도와주세요. 지금은 움직이지 않습니다. x = 235, y = 0에서 x = 235, y = 235까지 움직일 필요가 있습니다. 여기에 코드가 있습니다 (볼의 움직임을 왼쪽에서 오른쪽으로 변경했기 때문에 지저분하지만 아래로 내려갈 수는 없습니다).애니메이션 : 원/공을 y 축 아래로 똑바로 움직이는 방법
import java.awt.Color;
import java.awt.Graphics;
public class Animation {
public static void main(String [] args) {
DrawingPanel panel = new DrawingPanel(350, 350);
Graphics g = panel.getGraphics();
background(g);
ballroll(panel, g);
}
public static void ballroll(DrawingPanel panel, Graphics g) {
//draw and roll the ball now
g.setColor(Color.RED);
int x = 245, y = 0, direction=1;
while(y<245){
g.fillOval(235, 0, 20, 20);
//if (x==0){
y+=60;
direction *= -1;
}
//else if (x < 115){
//direction *= -1;
//y+=60;
//}
y+=direction*15;
System.out.println(x);
panel.sleep(80);
}
panel.sleep(350);
//}
}
가능한 복제 [애니메이션 : 어떻게 y 축 아래로 "롤"원에 (http://stackoverflow.com/questions/40582775/animation-how-to-roll-circle -down-the-y-axis) – Spektre
중복 된 질문을 게시하지 말고 원본 질문에 새 정보를 편집으로 추가하십시오. – Spektre