Hi, I have this simple array inside my variable with some colors.
var clr = ['#FF0000', '#0000FF', '#FFFF00', '#008000', '#FFA500', '#800080', '#ffffff'];
and then a function that should return one of these values in single quotes
function colors() {
var color;
color = "'";
color += Math.floor(Math.random() * clr.length);
color += "'";
return color;
}
this function is then called to display various colored balls
function CreateBall(x, y, vx, vy, r, s) {
this.color = colors();
this.x = x;
this.y = y;
this.vx = vx;
this.vy = vy;
this.r = r;
this.size = s;
}
However, this does not work? Any ideas why?
To see the full code, see the source here: http://dev.driz.co.uk/pool
source
share