Sketch with classes implementation in a Reactjs project

@GoToLoop LEGEND!

Since my project is a Reactjs “app” it does bundles the p5js and matterjs libraries in deed.

I had a look at your code (thank you for the time and effor to work on the examples friking legend you are), I noticed something on the Ball class: constructor(world, p = p5.instance) I’ve never seeing that before, do you mind elaborate?

My take on passing the p5js reference to the Ball class was:

constructor(world, p) {
    this.world = world;
    this.p = p;
}

and then this.p.[method] every time I need a p5js function like: this.p.ellipse(this.p.mouseX, this.p.mouseY);

But your implementation is cleaner with p5.instance. I take is a feature of p5js only right?

1 Like