/* Constants */
var START_RADIUS = 1;
var INCREMENT = 1;
var CHANGE_COLORS_AT = 10;
var circle;
function start(){
//Circle is being added once in the start function.
circle = new Circle(START_RADIUS);
circle.setPosition(getWidth()/2, getHeight()/2);
add(circle);
//This is the command that will execute every 50 miliseconds.
setTimer(grow, 50);
}
function grow(){
//This will keep the circle from continually growing past the height of the (premade) canvas.
while(circle.getRadius()*2 != getHeight()){
START_RADIUS = START_RADIUS + INCREMENT;
circle.setRadius(START_RADIUS);
//Changes the color every +10 the radius grows.
if(circle.getRadius() % CHANGE_COLORS_AT == 0){
circle.setColor(Randomizer.nextColor());
}
}
}
이 코드는 지름이 캔버스 상단에 닿을 때까지 지속적으로 커지는 원을 만들기위한 것입니다. 이것은 학교용이며 'codehs.com'웹 사이트에서 매우 단순화 된 버전의 자바 스크립트를 사용하고 있습니다. 나는이 코드에 대해 잠시 동안 작업 해왔고이를 수정하는 방법에 대한 통찰력을 원합니다.코드 수정에 도움을 드리고 싶습니다.
'getHeight' 및 다른 getter는 어떻게 정의됩니까? – Teemu
JavaScript! = Java –
무엇이 문제입니까? –