We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I got this sketch : http://codepen.io/giorgiomartini/pen/oLJyBj?editors=0011 and I want to have a point class, that draws the point using a vector.
But i get an error in the codepen console and it doesnt draw the point on the screen: Did you just try to use p5.js's createVector() function? If so, you may want to move it into your sketch's setup() function
But.. the createVector function is and i think it should stay on my point class...
Any idea where's the problem?
Thanks :)
Answers
http://CodePen.io/anon/pen/wWNmpR?editors=1010
"index.html":
"PointClass.js":
@giorgiomartini 'point' is a global variable defined by p5; so you have to name your point instance something else; or use instance mode (recommended).
new
Point to it in setup():window.point(this.pos.x, this.pos.y);
You know that my opinion is that the ideal would be for point() NOT to be a global variable :P
OK, in order to prove your "point" about under "instance mode" we can freely create global variables w/ the same name as p5.js' API, the sketch is using it now. :-\"
Although I don't like to use Processing's API as variable & method names at all, in order to avoid confusion and erroneous posted code's color highlighting. 3:-O
http://CodePen.io/anon/pen/wWNmVL?editors=1010
"index.html":
"PointClass.js":
Thanks! :)