From bb9761aaf42bd2198b1466f9f29a627f5673e018 Mon Sep 17 00:00:00 2001 From: Webeled Date: Mon, 16 Sep 2013 17:40:56 +0200 Subject: [PATCH] It loops but still problems on the constructor --- examples/audio/loop.php | 11 +++----- examples/display/render crisp.php | 44 +++++++++++++++++++++++++++++++ src/core/Stage.js | 2 +- src/core/World.js | 2 +- src/sound/Sound.js | 9 +++++-- src/sound/SoundManager.js | 16 ++++++++++- 6 files changed, 71 insertions(+), 13 deletions(-) create mode 100644 examples/display/render crisp.php diff --git a/examples/audio/loop.php b/examples/audio/loop.php index cfbc76de4..1be5f0db6 100644 --- a/examples/audio/loop.php +++ b/examples/audio/loop.php @@ -7,7 +7,7 @@ (function () { - var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update, render: render }); + var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create}); function preload() { @@ -27,20 +27,15 @@ music = game.add.audio('squit',1,true); - music.play(); + + music.play('',0,1,true); s = game.add.sprite(game.world.centerX, game.world.centerY, 'spyro'); s.anchor.setTo(0.5, 0.5); } - function update() { - //s.rotation += 0.01; - } - function render() { - game.debug.renderSoundInfo(music, 20, 32); - } })(); diff --git a/examples/display/render crisp.php b/examples/display/render crisp.php new file mode 100644 index 000000000..e5e1917a6 --- /dev/null +++ b/examples/display/render crisp.php @@ -0,0 +1,44 @@ + + + + + + diff --git a/src/core/Stage.js b/src/core/Stage.js index 12859f869..5a4e07e66 100644 --- a/src/core/Stage.js +++ b/src/core/Stage.js @@ -10,7 +10,7 @@ * @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License -* @class Phaser.Camera +* @class Stage * @constructor * @param game {Phaser.Game} game reference to the currently running game. * @param width {number} width of the canvas element diff --git a/src/core/World.js b/src/core/World.js index 9fb89b6eb..36319967a 100644 --- a/src/core/World.js +++ b/src/core/World.js @@ -115,7 +115,7 @@ Phaser.World.prototype = { /** * Destroyer of worlds. - * @method setSize + * @method destroy */ destroy: function () { diff --git a/src/sound/Sound.js b/src/sound/Sound.js index 3f685c20f..e51264aeb 100644 --- a/src/sound/Sound.js +++ b/src/sound/Sound.js @@ -20,6 +20,7 @@ Phaser.Sound = function (game, key, volume, loop) { this._volume = volume; this.markers = {}; + /** * Reference to AudioContext instance. */ @@ -109,7 +110,7 @@ Phaser.Sound.prototype = { addMarker: function (name, start, stop, volume, loop) { volume = volume || 1; - loop = loop || false; + if (typeof loop == 'undefined') { loop = false; } this.markers[name] = { name: name, @@ -187,7 +188,9 @@ Phaser.Sound.prototype = { /** * Play this sound, or a marked section of it. + * @param marker {string} Assets key of the sound you want to play. + * @param position {number} the starting position * @param [volume] {number} volume of the sound you want to play. * @param [loop] {bool} loop when it finished playing? (Default to false) * @return {Sound} The playing sound object. @@ -200,7 +203,9 @@ Phaser.Sound.prototype = { if (typeof loop == 'undefined') { loop = false; } if (typeof forceRestart == 'undefined') { forceRestart = false; } - // console.log('play ' + marker + ' position ' + position + ' volume ' + volume + ' loop ' + loop); + + + console.log('play ' + marker + ' position ' + position + ' volume ' + volume + ' loop ' + loop); if (this.isPlaying == true && forceRestart == false && this.override == false) { diff --git a/src/sound/SoundManager.js b/src/sound/SoundManager.js index c43e06c3f..88501bbb1 100644 --- a/src/sound/SoundManager.js +++ b/src/sound/SoundManager.js @@ -1,6 +1,9 @@ /** * Phaser - SoundManager * +* @class SoundManager +* @constructor +* @param game {Phaser.Game} reference to the current game instance. */ Phaser.SoundManager = function (game) { @@ -225,10 +228,21 @@ Phaser.SoundManager.prototype = { }, + + /** + * + * @method add + * @param key {string} Asset key for the sound. + * @param volume {number} default value for the volume. + * @param loop {bool} Whether or not the sound will loop. + */ + add: function (key, volume, loop) { volume = volume || 1; - loop = loop || false; + if (typeof loop == 'undefined') { loop = false; } + + var sound = new Phaser.Sound(this.game, key, volume, loop);