We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSound,  Music Libraries › Mouse click to initialize sound
Page Index Toggle Pages: 1
Mouse click to initialize sound? (Read 612 times)
Mouse click to initialize sound?
Jan 3rd, 2008, 7:56pm
 
Hey,

Im pretty basic when it comes to processing. Im using Ess.jar to do some spectral analysis graphics at the moment.

Anyways, i have an image i want to click to play sound files in my data folder. What is the coding for this type of mouse interaction ?

If someone could help it would be much appreciated. Many thanks,

Steve.
Re: Mouse click to initialize sound?
Reply #1 - Jan 3rd, 2008, 9:46pm
 
If I understand you right, you're looking for a way to check if the mouseclick was made in the image area.

Code:

void mousePressed(){
if (mouseX > imgPositionX &&
mouseX < imgPositionX+img.width &&
mouseY > imgPositionY &&
mouseY < imgPosition+img.height) {
doSomeThing here
}
}
Re: Mouse click to initialize sound?
Reply #2 - Jan 4th, 2008, 5:26pm
 
hmm, my knowledge of processing is too basic so im finding this tricky. I think that coding might work - ill play around with it and see if i get any results.

Basically, im using an image as a button - when the image is clicked with the mouse, a sound or music clip will play.
Page Index Toggle Pages: 1