Made so that only the owner of the source can change the status of it

This commit is contained in:
Ziver Koc 2007-03-18 15:17:39 +00:00
parent dd696b2760
commit f25b07910e
3 changed files with 260 additions and 165 deletions

View file

@ -8,9 +8,11 @@ import ei.engine.scene.Entity;
* @author Kevin Glass
*/
public class Sound extends Entity{
private static int soundId = 1;
/** The buffer containing the sound */
private int buffer;
private int source;
private int sourceId;
private int id;
/**
* Create a new sound
@ -20,34 +22,66 @@ public class Sound extends Entity{
*/
public Sound(String name, String ref) {
super(name);
this.buffer = SoundLoader.getInstnace().loadSound(ref);
id = soundId;
soundId++;
this.buffer = SoundLoader.getInstnace().loadSound(ref);
}
/**
* Returns the unique id of the object
*
* @return The id of the object
*/
public int getSoundId(){
return id;
}
/**
* Returns the source this object uses
*
* @return The id of the source
*/
public int getSourceId(){
return sourceId;
}
/**
* Returns the buffer of this object
*
* @return The buffer
*/
public int getBuffer(){
return buffer;
}
/**
* Play this sound as a sound effect
*
*/
public void play() {
source = SoundLoader.getInstnace().playSound(buffer, true);
sourceId = SoundManager.getInstnace().playSound(this, false);
update();
}
/**
* Loop this sound
*
*/
public void loop() {
SoundLoader.getInstnace().playSound(buffer, true);
SoundManager.getInstnace().playSound(this, true);
update();
}
public void update() {
//AL10.alSource(source.get(0), AL10.AL_POSITION, sourcePos);
SoundLoader.getInstnace().setSoundLocation(
source, getLocation().getX(),getLocation().getY(),0);
SoundManager.getInstnace().setSoundLocation(
this, getLocation().getX(),getLocation().getY(),0);
}
/**
* unimplamented method
*
*/
public void render() {}
}