How to integrate sound in simple ticckle exapmle?
in
Programming Questions
•
3 months ago
I want to play sound also, when the mouse is over my smiley... How to do it?
(Thanks!)
(Thanks!)
- String message = "☺";
float x, y;
float horisontalR, verticalR;
void setup() {
size(300, 300);
textFont(createFont("Georgia", 120));
textAlign(CENTER, CENTER);
horisontalR = textWidth(message) / 2;
verticalR = (textAscent() + textDescent()) / 2;
noStroke();
x = width / 2;
y = height / 2;
}
void draw() {
fill(205, 120);
rect(0, 0, width, height);
if (abs(mouseX - x) < horisontalR &&
abs(mouseY - y) < verticalR) {
x += random(-5, 5);
y += random(-5, 5);
}
fill(0);
text("☺", x, y);
}
1