Ok here is the code. I am trying to build animation with this. I am here so far. I was unable to get (x=mouseX || y = mouseY) it says expected is "1="
Also, instead of x and y anywhere I press song one plays. I just want it to be played when pressed on rect(x,y,w,t). This is why, I was thinking to give it a variable. I am trying to give them as button. I know, I can get code for button. However, I am new and have to finish project. So, I just thought to make rectangles as buttons to play different songs.
Please help. Thank You.
Maxim maxim;
AudioPlayer player;
AudioPlayer player2;
boolean buttonOn;
int x=0;
int y=0;
int w=200;
int t=100;
void setup()
{
size(640, 960);
maxim = new Maxim(this);
player = maxim.loadFile("Native Deen.wav");
player.setLooping(true);
player2 = maxim.loadFile("Music 2.wav");
player2.setLooping(true);
player.volume(0.25);
background(0);
rectMode(CORNER);
}
void draw()
{
strokeWeight(6);
stroke(0, 255, 0);
fill(200, 200, 255);
rect(x, y, w, t);
buttonOn = false;
fill(255, 100, 0, 128);
rect(0, 100, 200, 100);
fill(255, 100, 0, 128);
rect(0, 200, 200, 100);
}
void mousePressed()
{
if (x != mouseX || y != mouseY); {
player.play();
//toggle the boolean
// to the opposite state
buttonOn = !buttonOn;
// now change the state
// of the player based on the
// new state of the boolean
if (buttonOn){
player.cue(0);
player.play();
}
else {
player.stop();
}
}