Hello,
Is it possible to access P5js functions in a static functions ?
I tried in this sketch but it doesnt work
"use strict";
function setup() {
createCanvas(800, 600);
fill(255);
}
function draw() {
background(0);
text(V.get("Hello", "number", this), 100, 100);
}
class V {
static verif=true;
static get(a, s, n) { // (anyType, type in a string, this) : anyType
if (!V.verif) {
return a;
} else if ( typeof a === s) {
return a;
} else {
let type = typeof a;
bugMessage("Erreur V, in : "+n+", asked : "+s+", but it was : "+type,true);
return 0;
}
}
}
function bugMessage(aString, aBoolean) {
print(aString);
if (aBoolean) {
noLoop();
}
}
I haven’t any error in the browser console
but it shows me something in P5 and it doesn’t work :
I wanted the sketch to stop (noLoop()) and my error message written in the console.
it works when I don’t use bugMessage(), it doesn’t work when I have noLoop() in the static method either.