I've done the coding, however I'm getting a NullPointerException error. All I want is for whenever the user clicks the mouse, it plays a sound on a loop, and when the mouse is released the sound stops. What am I doing wrong?
Much appreciated.
first circle_; second_[] smallcircle = new second_[4000];
import ddf.minim.* ; Minim minim;
AudioPlayer au_player1 ;
// Button Features boolean knobHighlight1 = false; boolean knobHighlight2 = false; float knob1, knobOne, knob2, knobTwo; int xKnob1; int yKnob1; int yKnob2; int knobMass; PImage bg;
void setup() { size(640,480);
minim = new Minim(this); au_player1 = minim.loadFile("bubbles.wav");
textSize(30); text("Fill My World With Colour",50,50); textAlign(CENTER,CENTER);
circle_ =new first ();
for (int s = 0; s <100; s++) { circle_ = new first(); smallcircle[s]=new second_(); }
// Boolean To Cause Action Once Mouse Is Pressed void update(int x, int y) { if ( knobHighlight1(xKnob1, yKnob1, knobMass)) { knobHighlight1 = true; knobHighlight2 = false; } else if ( knobHighlight2(xKnob1, yKnob2, knobMass) ) { knobHighlight1 = false; knobHighlight2 = true; } }
// Position of the Knobs boolean knobHighlight1(int x, int y, int diameter) { float xRange = x - mouseX; float yRange = y - mouseY; if (sqrt(sq(xRange) + sq(yRange)) < 15 ) { return true; } else { return false; } }
boolean knobHighlight2(int x, int y, int diameter) { float xRange = x - mouseX; float yRange = y - mouseY; if (sqrt(sq(xRange) + sq(yRange)) < 15 ) { return true; } else { return false; } }
void knob1pressed() { if (mousePressed==true) { fill(0); circle_.draw_(); noStroke(); fill(random(0, 255)); } } void knob2pressed() { if (mousePressed==true) { for (int s = 0; s < 50; s++) { fill(0); smallcircle[s].draw_(); smallcircle[s].move(); } } }