diff --git a/examples/assets/audio/SoundEffects/squit.mp3 b/examples/assets/audio/SoundEffects/squit.mp3 new file mode 100644 index 000000000..24a6d7e9c Binary files /dev/null and b/examples/assets/audio/SoundEffects/squit.mp3 differ diff --git a/examples/assets/audio/SoundEffects/squit.ogg b/examples/assets/audio/SoundEffects/squit.ogg new file mode 100644 index 000000000..e28915bac Binary files /dev/null and b/examples/assets/audio/SoundEffects/squit.ogg differ diff --git a/examples/audio/loop.php b/examples/audio/loop.php new file mode 100644 index 000000000..1be5f0db6 --- /dev/null +++ b/examples/audio/loop.php @@ -0,0 +1,46 @@ + + + + + diff --git a/examples/buttons/action on click.php b/examples/buttons/action on click.php new file mode 100644 index 000000000..ad4e34444 --- /dev/null +++ b/examples/buttons/action on click.php @@ -0,0 +1,48 @@ + + + + + diff --git a/examples/buttons/changing the frames.php b/examples/buttons/changing the frames.php new file mode 100644 index 000000000..f61316c4d --- /dev/null +++ b/examples/buttons/changing the frames.php @@ -0,0 +1,55 @@ + + + + + diff --git a/examples/buttons/rotated buttons.php b/examples/buttons/rotated buttons.php new file mode 100644 index 000000000..44d333697 --- /dev/null +++ b/examples/buttons/rotated buttons.php @@ -0,0 +1,56 @@ + + + + + diff --git a/examples/camera/basic follow.php b/examples/camera/basic follow.php new file mode 100644 index 000000000..c44fa5606 --- /dev/null +++ b/examples/camera/basic follow.php @@ -0,0 +1,76 @@ + + + + + + diff --git a/examples/camera/moving the game camera.php b/examples/camera/moving the game camera.php new file mode 100644 index 000000000..d1dcb921b --- /dev/null +++ b/examples/camera/moving the game camera.php @@ -0,0 +1,60 @@ + + + + + + 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/examples/sprites/sprite4.php b/examples/sprites/sprite4.php index fbbc121ad..161c1830a 100644 --- a/examples/sprites/sprite4.php +++ b/examples/sprites/sprite4.php @@ -17,8 +17,6 @@ function create() { - // game.world._stage.backgroundColorString = '#182d3b'; - s = game.add.sprite(game.world.centerX, game.world.centerY, 'bot'); // s.anchor.setTo(0.5, 0.5); s.scale.setTo(2, 2); diff --git a/examples/sprites/sprite2.php b/examples/sprites/spritesheet.php similarity index 100% rename from examples/sprites/sprite2.php rename to examples/sprites/spritesheet.php diff --git a/src/core/Camera.js b/src/core/Camera.js index 4d0cf1c19..b738e5f52 100644 --- a/src/core/Camera.js +++ b/src/core/Camera.js @@ -3,6 +3,15 @@ * * A Camera is your view into the game world. It has a position and size and renders only those objects within its field of view. * The game automatically creates a single Stage sized camera on boot. Move the camera around the world with Phaser.Camera.x/y +* +* @class Phaser.Camera +* @constructor +* @param game {Phaser.Game} game reference to the currently running game. +* @param id {number} not being used at the moment, will be when Phaser supports multiple camera +* @param x {number} position of the camera on the X axis +* @param y {number} position of the camera on the Y axis +* @param width {number} the width of the view rectangle +* @param height {number} the height of the view rectangle */ Phaser.Camera = function (game, id, x, y, width, height) { diff --git a/src/core/Stage.js b/src/core/Stage.js index bbdf967b1..5a4e07e66 100644 --- a/src/core/Stage.js +++ b/src/core/Stage.js @@ -8,6 +8,13 @@ * @author Richard Davey * @copyright 2013 Photon Storm Ltd. * @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License + + +* @class Stage +* @constructor +* @param game {Phaser.Game} game reference to the currently running game. +* @param width {number} width of the canvas element +* @param height {number} height of the canvas element */ Phaser.Stage = function (game, width, height) { diff --git a/src/core/World.js b/src/core/World.js index 92c153e0d..36319967a 100644 --- a/src/core/World.js +++ b/src/core/World.js @@ -11,6 +11,10 @@ * @author Richard Davey * @copyright 2013 Photon Storm Ltd. * @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License + + * @class World + * @constructor + * @param game {Phaser.Game} reference to the current game instance. */ Phaser.World = function (game) { @@ -91,7 +95,7 @@ Phaser.World.prototype = { /** * Updates the size of this world. - * + * @method setSize * @param width {number} New width of the world. * @param height {number} New height of the world. */ @@ -111,6 +115,7 @@ Phaser.World.prototype = { /** * Destroyer of worlds. + * @method destroy */ destroy: function () { diff --git a/src/gameobjects/Button.js b/src/gameobjects/Button.js index 5a063fe71..9aea56349 100644 --- a/src/gameobjects/Button.js +++ b/src/gameobjects/Button.js @@ -1,5 +1,7 @@ /** * Create a new Button object. +* @class Button +* @constructor * * @param game {Phaser.Game} Current game instance. * @param [x] {number} X position of the button. @@ -58,7 +60,15 @@ Phaser.Button = function (game, x, y, key, callback, callbackContext, overFrame, Phaser.Button.prototype = Phaser.Utils.extend(true, Phaser.Sprite.prototype, PIXI.Sprite.prototype); Phaser.Button.prototype.constructor = Phaser.Button; -// Add our own custom methods +/** +* Used to manually set the frames that will be used for the different states of the button +* exactly like setting them in the constructor +* +* @method setFrames +* @param [overFrame] {string|number} This is the frame or frameName that will be set when this button is in an over state. Give either a number to use a frame ID or a string for a frame name. +* @param [outFrame] {string|number} This is the frame or frameName that will be set when this button is in an out state. Give either a number to use a frame ID or a string for a frame name. +* @param [downFrame] {string|number} This is the frame or frameName that will be set when this button is in a down state. Give either a number to use a frame ID or a string for a frame name. +*/ Phaser.Button.prototype.setFrames = function (overFrame, outFrame, downFrame) { diff --git a/src/sound/Sound.js b/src/sound/Sound.js index 9774fbb0d..e51264aeb 100644 --- a/src/sound/Sound.js +++ b/src/sound/Sound.js @@ -1,7 +1,17 @@ +/** +* The Sound class +* +* @class Sound +* @constructor +* @param game {Phaser.Game} reference to the current game instance. +* @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. +*/ Phaser.Sound = function (game, key, volume, loop) { volume = volume || 1; - loop = loop || false; + if (typeof loop == 'undefined') { loop = false; } this.game = game; this.name = ''; @@ -10,6 +20,7 @@ Phaser.Sound = function (game, key, volume, loop) { this._volume = volume; this.markers = {}; + /** * Reference to AudioContext instance. */ @@ -99,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, @@ -177,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. @@ -187,10 +200,12 @@ Phaser.Sound.prototype = { marker = marker || ''; position = position || 0; volume = volume || 1; - loop = loop || false; - forceRestart = forceRestart || false; + 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) { @@ -356,7 +371,7 @@ Phaser.Sound.prototype = { marker = marker || ''; position = position || 0; volume = volume || 1; - loop = loop || false; + if (typeof loop == 'undefined') { loop = false; } this.play(marker, position, volume, loop, true); 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);