From ba37049c44ff64b3c6482a5e2f199f178351a69f Mon Sep 17 00:00:00 2001 From: Comment Date: Tue, 29 Jan 2013 01:52:00 +0000 Subject: mostly working --- src/boundary.cpp | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) (limited to 'src/boundary.cpp') diff --git a/src/boundary.cpp b/src/boundary.cpp index 64957ed..2425c4a 100755 --- a/src/boundary.cpp +++ b/src/boundary.cpp @@ -5,9 +5,10 @@ boundary::boundary() filename=""; } -boundary::boundary(string file) +boundary::boundary(string file,float vol) { - filename=file; + openFile(file); + sound.setVolume(vol); } boundary::~boundary() @@ -77,7 +78,28 @@ bool boundary::contains(ofPoint p) else return true; } - -void boundary::checkfile(ofPoint pos,string file) { - if (contains(pos)) filename=file; +void boundary::openFile(string file) { + filename=file; + if (filename.length()>0) { + if (sound.loadSound(filename)) sound.setLoop(false); + else printf("failed to load %s\n",filename.c_str()); + } +} +bool boundary::checkFile(ofPoint pos,string file) { + if (contains(pos)) { + sound.stop(); + openFile(file); + return true; + } + else return false; +} +bool boundary::checkClick(ofPoint pos){ + if (contains(pos)&&sound.isLoaded()&&!sound.getIsPlaying()) { + sound.play(); + return true; + } + else return false; } +void boundary::setVolume(float vol){ + sound.setVolume(vol); +} -- cgit v1.2.3