Add positional sounds from the tilemap

This commit is contained in:
2014-06-13 23:19:20 -07:00
parent 4505486bf7
commit c96610c899

View File

@@ -90,23 +90,7 @@ SoundSprite.prototype = Object.create(Phaser.Sprite.prototype);
SoundSprite.prototype.constructor = Light; SoundSprite.prototype.constructor = Light;
SoundSprite.prototype.update_new_values = function() { SoundSprite.prototype.update_new_values = function() {
if ( this.sound_key == null ) { this.adjust_relative_to = function(spr) {
if ( this.sound !== null ) {
this.sound.stop();
}
return;
}
this.sound = game.add.audio(this.sound_key);
this.sound.play(
this.sound_marker,
this.sound_position,
this.sound_volume,
this.sound_loop,
this.sound_forcerestart);
console.log("Sound should be playing");
}
SoundSprite.prototype.adjust_relative_to = function(spr) {
console.log(spr); console.log(spr);
if ( this.sound_nofade == true ) { if ( this.sound_nofade == true ) {
this.sound.volume = 1.0; this.sound.volume = 1.0;
@@ -132,6 +116,22 @@ SoundSprite.prototype.adjust_relative_to = function(spr) {
console.log([hyp_perfect, hyp, this.sound.volume]); console.log([hyp_perfect, hyp, this.sound.volume]);
} }
if ( this.sound_key == null ) {
if ( this.sound !== null ) {
this.sound.stop();
}
return;
}
this.sound = game.add.audio(this.sound_key);
this.sound.play(
this.sound_marker,
this.sound_position,
this.sound_volume,
this.sound_loop,
this.sound_forcerestart);
console.log("Sound should be playing");
}
var moonlightSettings = { var moonlightSettings = {
'map' : { 'map' : {
'tilesets': [ 'tilesets': [
@@ -1078,6 +1078,7 @@ GameState.prototype.update = function()
} }
function _fix_audio_relative(x) { function _fix_audio_relative(x) {
console.log(x);
x.adjust_relative_to(this.player); x.adjust_relative_to(this.player);
} }
this.staticSounds.forEach(_fix_audio_relative, this); this.staticSounds.forEach(_fix_audio_relative, this);