I am new to OO in JavaScript and trying to make this simple canvas demo:
var c; // typeof c is the canvas element
function SolarSystem(plane, sun) {
this.plane = plane; // typeof plane is object,Canvas aCtxt
Canvas 2D Context
this.sun = sun;
this.init = function () {
draw();
}
this.render = function () {
c.height = c.height;
requestAnimationFrame(this.render);
this.draw();
}
this.draw = function () {
console.log(1);
}
}
}
What I want to do is, to render SolarSystem, I want to call render() that is inside of it. I cannot call render() from render(), how can I do that without getting Uncaught TypeError: Type error in the console? Thanks!