hello!
I’m producing two canvases on Instance Mode, my plan is to be able to mouseScroll on just one canvas, but I can’t make it work.
I believe… I’m making a name function that is called from mousewheel in the first canvas setup and I’m sure i’m doing something terrible wrong… I don’t really understand well Instance mode.
thoughts?
https://editor.p5js.org/caminofarol/sketches/6t5QmGWU
var pgPos = 50;
var s1 = function( p ) {
p.setup = function() {
var canvas1 = p.createCanvas(400, 400);
canvas1.mouseWheel(doScroll);
canvas1.position(0,0);
}
p.draw = function() {
p.background(128);
p.translate(50, pgPos);
p.fill(255);
p.rect(0,0, 300, 200);
}
var doScroll = function() {
pgPos += event.delta;
}
};
new p5(s1);
var s2 = function( p ) {
p.setup = function() {
var canvas2 = p.createCanvas(400, 400);
canvas2.position(400,0);
}
p.draw = function() {
p.background(160);
p.rect(0,0, 300, 200);
}
};
new p5(s2);