Skip to content

Commit

Permalink
It loops but still problems on the constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
Webeled committed Sep 16, 2013
1 parent fc584cf commit bb9761a
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 13 deletions.
11 changes: 3 additions & 8 deletions examples/audio/loop.php
Original file line number Diff line number Diff line change
Expand Up @@ -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() {

Expand All @@ -27,20 +27,15 @@ function create() {


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);
}

})();

Expand Down
44 changes: 44 additions & 0 deletions examples/display/render crisp.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php
$title = "Canvas Smoothing";
require('../head.php');
?>

<script type="text/javascript">

(function () {

var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create });

function preload() {

game.load.image('boss', 'assets/misc/boss1.png');
game.load.spritesheet('button', 'assets/buttons/button_sprite_sheet.png', 193, 71);

}
var boss,
button;

function create() {

// For browsers that support it, this keeps our pixel art looking crisp
//Phaser.Canvas.setSmoothingEnabled(game.stage.canvas.context, false);

boss = game.add.sprite(game.world.centerX, game.world.centerY, 'boss');
boss.anchor.setTo(0.5, 0.5);
// Zoom in each time we press it
button = game.add.button(32, 32, 'button', clickedIt, this, 2, 1, 0);
}

function clickedIt() {
boss.scale.x += 0.5;
boss.scale.y += 0.5;
}

})();

</script>

<?php
require('../foot.php');
?>

2 changes: 1 addition & 1 deletion src/core/Stage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/core/World.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ Phaser.World.prototype = {

/**
* Destroyer of worlds.
* @method setSize
* @method destroy
*/
destroy: function () {

Expand Down
9 changes: 7 additions & 2 deletions src/sound/Sound.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Phaser.Sound = function (game, key, volume, loop) {
this._volume = volume;
this.markers = {};


/**
* Reference to AudioContext instance.
*/
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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.
Expand All @@ -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)
{
Expand Down
16 changes: 15 additions & 1 deletion src/sound/SoundManager.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
/**
* Phaser - SoundManager
*
* @class SoundManager
* @constructor
* @param game {Phaser.Game} reference to the current game instance.
*/
Phaser.SoundManager = function (game) {

Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit bb9761a

Please sign in to comment.