let bubble;
function setup() {
createCanvas(600, 400);
bubble = new Bubble();
print(bubble.x, bubble.y);
}
function draw() {
background(0);
}
class Bubble {
contructor(x, y) {
this.x = 200;
this.y = 150;
}
}```
I've been following along with the Code! lessons and I'm having issues with the lesson "Classes in ES6". When running this, copying shiffman's example line for line, the result is "undefined undefined" for the print of x and y. What seems to be the cause and what would be the remedy?
#Classes in ES6: Undefined x and y
10 messages · Page 1 of 1 (latest)
you didn't pass anything into the constructor
it should be like new Bubble(10, 20)
if you passed in no arguments, js will treat it as new Bubble(undefined, undefined)
oh wait, nvm, sorry
misread your code
If anything, this is shiffman's code, just copied
but I'll keep that in mind, still learning here
oh, constructor is misspelled
that's the problem
ty lol