summaryrefslogtreecommitdiff
path: root/src/boundary.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/boundary.cpp')
-rwxr-xr-xsrc/boundary.cpp32
1 files changed, 27 insertions, 5 deletions
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);
+}