We are about to switch to a new forum software. Until then we have removed the registration on this forum.
In Instance Mode, how do I write events function ? For example, I do not know how to write "mousePressed" in this code (Instance Mode): This is not explained in this reference page: http://p5js.org/learn/examples/Instance_Mode_Instantiation.php
var sketch1 = function( p ) {
var x = 100;
var y = 100;
var myColor = 127;
p.setup = function() {
p.createCanvas(700, 410);
};
p.draw = function() {
p.background(0);
p.fill(myColor);
p.rectMode(p.CENTER);
p.rect(p.mouseX,p.mouseY,50,50);
};
//HERE !!! HERE !!! HERE !!! HERE !!! HERE !!! HERE !!! HERE !!! :
// p.mousePressed = function() {... ???
// p.mousePressed() = function() {... ???
// mousePressed = p.function() {... ???
};
Answers
I found the Answer here: https://github.com/processing/p5.js/wiki/Instantiation-Cases
I've helped to re-edit the examples there too! ^_^