Map work
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -79,6 +79,7 @@ function SoundSprite(game, x, y, key, frame,
|
|||||||
sound_volume,
|
sound_volume,
|
||||||
sound_loop,
|
sound_loop,
|
||||||
sound_forcerestart,
|
sound_forcerestart,
|
||||||
|
sound_distance,
|
||||||
sound_nofade)
|
sound_nofade)
|
||||||
{
|
{
|
||||||
Phaser.Sprite.call(this, game, x, y, null);
|
Phaser.Sprite.call(this, game, x, y, null);
|
||||||
@@ -88,6 +89,11 @@ function SoundSprite(game, x, y, key, frame,
|
|||||||
this.sound_position = ( typeof sound_position == undefined ? sound_position : 1.0 );
|
this.sound_position = ( typeof sound_position == undefined ? sound_position : 1.0 );
|
||||||
this.sound_loop = ( typeof sound_loop == undefined ? sound_loop : true );
|
this.sound_loop = ( typeof sound_loop == undefined ? sound_loop : true );
|
||||||
this.sound_forcerestart = ( typeof sound_forcerestart == undefined ? sound_forcerestart : true );
|
this.sound_forcerestart = ( typeof sound_forcerestart == undefined ? sound_forcerestart : true );
|
||||||
|
var def_distance = Math.sqrt(
|
||||||
|
Number((game.camera.width/2) * (game.camera.width/2)) +
|
||||||
|
Number((game.camera.height/2) * (game.camera.height/2))
|
||||||
|
);
|
||||||
|
this.sound_distance = ( typeof sound_distance == undefined ? sound_distance : def_distance);
|
||||||
this.sound_nofade = (typeof sound_nofade == undefined ? sound_nofade : false);
|
this.sound_nofade = (typeof sound_nofade == undefined ? sound_nofade : false);
|
||||||
|
|
||||||
this.sound = null;
|
this.sound = null;
|
||||||
@@ -104,6 +110,7 @@ SoundSprite.prototype.update_new_values = function() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.sound_position = parseInt(this.sound_position);
|
this.sound_position = parseInt(this.sound_position);
|
||||||
|
this.sound_distance = Number(this.sound_distance);
|
||||||
this.sound_volume = Number(this.sound_volume);
|
this.sound_volume = Number(this.sound_volume);
|
||||||
this.sound_loop = parseBoolean(this.sound_loop);
|
this.sound_loop = parseBoolean(this.sound_loop);
|
||||||
this.sound_forcerestart = parseBoolean(this.sound_forcerestart);
|
this.sound_forcerestart = parseBoolean(this.sound_forcerestart);
|
||||||
@@ -136,12 +143,8 @@ SoundSprite.prototype.adjust_relative_to = function(spr) {
|
|||||||
yd = -(yd);
|
yd = -(yd);
|
||||||
|
|
||||||
var hyp = Math.sqrt(Number(xd * xd) + Number(yd * yd));
|
var hyp = Math.sqrt(Number(xd * xd) + Number(yd * yd));
|
||||||
var hyp_perfect = Math.sqrt(
|
|
||||||
Number((game.camera.width/2) * (game.camera.width/2)) +
|
|
||||||
Number((game.camera.height/2) * (game.camera.height/2))
|
|
||||||
);
|
|
||||||
|
|
||||||
this.sound.volume = (1.0 - Number(hyp / hyp_perfect));
|
this.sound.volume = (1.0 - Number(hyp / this.sound_distance));
|
||||||
// Math.max doesn't work here??
|
// Math.max doesn't work here??
|
||||||
if ( this.sound.volume < 0 )
|
if ( this.sound.volume < 0 )
|
||||||
this.sound.volume = 0;
|
this.sound.volume = 0;
|
||||||
@@ -889,7 +892,7 @@ GameState.prototype.create = function()
|
|||||||
}, this)
|
}, this)
|
||||||
|
|
||||||
this.effectSprites = game.add.group();
|
this.effectSprites = game.add.group();
|
||||||
this.map.createFromObjects('EffectSprites', 1837, 'player', 0, true, false, this.effectSprites, EffectSprite);
|
this.map.createFromObjects('EffectSprites', 5, 'player', 0, true, false, this.effectSprites, EffectSprite);
|
||||||
this.effectSprites.forEach(function(spr) {
|
this.effectSprites.forEach(function(spr) {
|
||||||
spr.update_new_values();
|
spr.update_new_values();
|
||||||
}, this)
|
}, this)
|
||||||
|
|||||||
Reference in New Issue
Block a user