xxxxxxxxxx
38
var count = 1;
function setup() {
createCanvas(400, 400);
myButton = new button();
myButton.place(width / 2, height / 2, 100, 50);
myButton.align(0, 0);
myButton.content = "Clicks: 0";
myButton.onClick = function () {
myButton.content = "Clicks: " + count;
count++;
};
}
function draw() {
background(220);
myButton.draw();
canne();
}
function canne() {
push();
translate(mouseX, mouseY);
strokeWeight(5);
line(-10, 20, 60, -120);
fill(204, 153, 0);
ellipse(0, 0, 33, 33);
if (mouseIsPressed) {
angleMode(DEGREES);
rotate(frameCount * 10);
}
translate(8, 0);
fill(0, 0, 0);
ellipse(0, 0, 4, 4);
pop();
}