이것은 이전에 자바에서 OOP를 해본 적이 있고이 문제가 없었던 이래로 저를 상당히 혼란스럽게 만드는 매우 간단한 질문입니다. 기본적으로 내가 문제의 객체를 생성하기 위해 클래스를 호출 할 때 일어나는 일은 아닙니다. 왜 이것이 작동하지 않는지 전혀 알지 못합니다. 자바가 단순화 된 처리 과정을 잘못 이해하고 있다고 가정합니다.클래스 처리 IDE에서 호출하지 않습니다
final color RED = color(255,0,0);
final color BLUE = color(0,0,255);
motorbike bike1;
motorbike bike2;
class motorbike
{
int x = 5;
//members
int y;
int speed=2;
int size=30;
color colour;
void render()
{
float wheelHeight = size/3;
fill(colour);
triangle(x,y,x+size,y,x+size/2,y-size/2);
//built-in triangle routine
drawWheel(x,y,wheelHeight);
drawWheel(x+size,y,wheelHeight);
}
void drawWheel(int x, int y,float size)
{
float inner = size*2/3;
fill(0);
ellipse(x,y,size,size);
fill(255);
ellipse(x,y,inner,inner);
}
void move()
{
speed= (int)random(5.0);
//a random step [0..5]
x=x+speed;
}
void update() {
move();
render();
}
motorbike(int y,color col){
//constructor
this.y=y;
this.speed= (int)random(5.0);
this.colour=col;
}
//endof class description
}
void setup()
{
size(500,100);
bike1 = new motorbike(RED,30);
bike2 = new motorbike(BLUE,60);
print("Come on");
}
void draw()
{
background(125);
}
정말 바보 같은 질문에 대해 미안하지만이 질문은 객체를 그리지 않는 이유를 모르겠습니다.
에서 당신이 전체 선언을 공유 할 필요가? 나는 시험하고 당신에게 피드백과 해결책을 보낼 필요가있다. – oetoni
위의 코드는 처리 중으로 보일 수도있다. – user3469829
'draw()'메소드는 배경을 설정하는 것 외에는 아무것도하지 않습니다. 무슨 일이 일어날 것으로 예상됩니까? –