Quantcast
Channel: Library Questions - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 2896

I can't stop sound

$
0
0

When ever I do :stop() the sound continues on playing. I don't get any errors and nothing in the output.

PImage background; PImage box; PImage HalfHalf; PImage Phone; PImage Skip; int MText = (42); int SText = (28); boolean Main = (true); boolean Game = (false); boolean QuestionStart = (false); import processing.sound.*; SoundFile MainSound; SoundFile QuestionSound; SoundFile CountdownSound; SoundFile LoseSound; SoundFile WinSound;

void setup() { size(800, 600); MainSound = new SoundFile(this, "Main.mp3"); QuestionSound = new SoundFile(this, "Questions.mp3"); CountdownSound = new SoundFile(this, "Countdown.mp3"); background = loadImage("Background.png"); box = loadImage("Box.png"); HalfHalf = loadImage("HalfHalf.png"); Phone = loadImage("Phone.png"); Skip = loadImage("Skip.png"); if (Main == true) { MainSound.loop(); } if (Game == true){ if (QuestionStart == true){ MainSound.stop(); CountdownSound.play(); }

} }

void draw() { image(background, 0, 0); if (Main == (true)) { image(box, 50, height-200, 200, 50); textSize(MText); text("Do you want to be a MILLIONAIRE?", 400, 50); textAlign(CENTER); textSize(SText); text("Yes!(Y)", 50+100, height-165); textSize(12); text("When you see brackets '(Y, or another letter)' in a button, ", 60+200, 100); text("that means you must press the key in the brackets to select it!", 60+200, 120); } if (Game == true){ image(background, 0, 0); textSize(MText); text("Question 1", 400, 50); textAlign(CENTER); if (QuestionStart == true){ image(box, 0, height-300, 800, 300); }

}

}

public void keyPressed(){ println("KeyPressed: " + keyCode); if (Main == true){if (key == 89){Main = false; Game = true; QuestionStart = true;}} }


Viewing all articles
Browse latest Browse all 2896

Trending Articles