Run once if ?!?!
in
Programming Questions
•
2 years ago
- class Square {
- float ex, wy;
- int nex, nwy;
- float area;
- Square(float W, float H) {
- area = 50;
- ex = W;
- wy = H;
- }
- void display() {
- area = area + sin(frameCount/16);
- if (area > 77) {
- fill(0); myBus.sendNoteOn(1, 36, 70);
- }
- else {
- fill(0, 121, 184);
- }
- strokeWeight(10);
- stroke(130);
- rectMode(CENTER);
- rect(ex, wy, area, area);
- }
I have created this class for a pulsing blue rectangle that when it gets to the larger end of its size turns black and makes a sound.
The problem is I do not know how to get it to do the myBus.sendNoteOn() function only once for each time it expands and goes black.
At the moment the note is simply repeated continuously (40 times a second I guess as that is the speed of the frame rate)
Can anybody help?
1