JSDocs update ;)

This commit is contained in:
Webeled
2013-09-19 16:34:48 +02:00
parent 78a062dfb6
commit 26a595cd44
8 changed files with 261 additions and 57 deletions
+8 -8
View File
@@ -117,8 +117,8 @@ Phaser.Camera.prototype = {
/**
* Tells this camera which sprite to follow.
* @method follow
* @param target {Phaser.Sprite} The object you want the camera to track. Set to null to not follow anything.
* @param [style] {number} Leverage one of the existing "deadzone" presets. If you use a custom deadzone, ignore this parameter and manually specify the deadzone after calling follow().
* @param {Phaser.Sprite} target The object you want the camera to track. Set to null to not follow anything.
* @param {number} [style] Leverage one of the existing "deadzone" presets. If you use a custom deadzone, ignore this parameter and manually specify the deadzone after calling follow().
*/
follow: function (target, style) {
@@ -157,8 +157,8 @@ Phaser.Camera.prototype = {
/**
* Move the camera focus to a location instantly.
* @method focusOnXY
* @param x {number} X position.
* @param y {number} Y position.
* @param {number} x X position.
* @param {number} y Y position.
*/
focusOnXY: function (x, y) {
@@ -260,8 +260,8 @@ Phaser.Camera.prototype = {
* without having to use game.camera.x and game.camera.y
*
* @method setPosition
* @param x {number} X position.
* @param y {number} Y position.
* @param {number} x X position.
* @param {number} y Y position.
*/
setPosition: function (x, y) {
@@ -275,8 +275,8 @@ Phaser.Camera.prototype = {
* Sets the size of the view rectangle given the width and height in parameters
*
* @method setSize
* @param width {number} the desired width.
* @param height {number} the desired height.
* @param {number} width The desired width.
* @param {number} height The desired height.
*/
setSize: function (width, height) {
+5 -5
View File
@@ -12,9 +12,9 @@
*
* @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
* @param {Phaser.Game} game Game reference to the currently running game.
* @param {number} width Width of the canvas element
* @param {number} height Height of the canvas element
*/
Phaser.Stage = function (game, width, height) {
@@ -64,7 +64,7 @@ Phaser.Stage = function (game, width, height) {
* The current scaleMode
* @property scaleMode
* @public
* @type {Phaser.StageScaleMode}
* @type {number}
*/
this.scaleMode = Phaser.StageScaleMode.NO_SCALE;
@@ -117,7 +117,7 @@ Phaser.Stage.prototype = {
/**
* This method is called when the document visibility is changed.
* @method visibilityChange
* @param event [Event] its type will be used to decide whether the game should be paused or not
* @param {Event} event Its type will be used to decide whether the game should be paused or not
*/
visibilityChange: function (event) {
+3 -3
View File
@@ -15,7 +15,7 @@
*
* @class World
* @constructor
* @param game {Phaser.Game} reference to the current game instance.
* @param {Phaser.Game} game Reference to the current game instance.
*/
Phaser.World = function (game) {
@@ -115,8 +115,8 @@ 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.
* @param {number} width New width of the world.
* @param {number} height New height of the world.
*/
setSize: function (width, height) {
+12 -12
View File
@@ -10,15 +10,15 @@
* @class Button
* @constructor
*
* @param game {Phaser.Game} Current game instance.
* @param [x] {number} X position of the button.
* @param [y] {number} Y position of the button.
* @param [key] {string} The image key as defined in the Game.Cache to use as the texture for this button.
* @param [callback] {function} The function to call when this button is pressed
* @param [callbackContext] {object} The context in which the callback will be called (usually 'this')
* @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.
* @param {Phaser.Game} game Current game instance.
* @param {number} [x] X position of the button.
* @param {number} [y] Y position of the button.
* @param {string} [key] The image key as defined in the Game.Cache to use as the texture for this button.
* @param {function} [callback] The function to call when this button is pressed
* @param {object} [callbackContext] The context in which the callback will be called (usually 'this')
* @param {string|number} [overFrame] 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 {string|number} [outFrame] 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 {string|number} [downFrame] 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 = function (game, x, y, key, callback, callbackContext, overFrame, outFrame, downFrame) {
@@ -73,9 +73,9 @@ Phaser.Button.prototype.constructor = Phaser.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.
* @param {string|number} [overFrame] 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 {string|number} [outFrame] 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 {string|number} [downFrame] 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) {
+107 -13
View File
@@ -3,26 +3,70 @@
*
* @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.
* @param {Phaser.Game} game Reference to the current game instance.
* @param {string} key Asset key for the sound.
* @param {number} volume Default value for the volume.
* @param {bool} loop Whether or not the sound will loop.
*/
Phaser.Sound = function (game, key, volume, loop) {
volume = volume || 1;
if (typeof loop == 'undefined') { loop = false; }
/**
* A reference to the currently running Game.
* @property game
* @public
* @type {Phaser.Game}
*/
this.game = game;
/**
* Name of the sound
* @property name
* @public
* @type {string}
*/
this.name = '';
/**
* Asset key for the sound.
* @property key
* @public
* @type {string}
*/
this.key = key;
/**
* Whether or not the sound will loop.
* @property loop
* @public
* @type {bool}
*/
this.loop = loop;
/**
* The global audio volume. A value between 0 (silence) and 1 (full volume)
* @property _volume
* @private
* @type {number}
*/
this._volume = volume;
/**
* The sound markers, empty by default
* @property markers
* @public
* @type {object}
*/
this.markers = {};
/**
* Reference to AudioContext instance.
* @property context
* @public
* @type {AudioContext}
*/
this.context = null;
@@ -31,9 +75,28 @@ Phaser.Sound = function (game, key, volume, loop) {
*/
this._buffer = null;
/**
* Boolean indicating whether the game is on "mute"
* @property _muted
* @private
* @type {bool}
*/
this._muted = false;
/**
* Boolean indicating whether the sound should start automatically
* @property autoplay
* @public
* @type {bool}
*/
this.autoplay = false;
/**
* The total duration of the sound, in milliseconds
* @property autoplay
* @public
* @type {bool}
*/
this.totalDuration = 0;
this.startTime = 0;
this.currentTime = 0;
@@ -188,11 +251,11 @@ 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)
* @method play
* @param {string} marker Assets key of the sound you want to play.
* @param {number} position The starting position
* @param {number} [volume] Volume of the sound you want to play.
* @param {bool} [loop] Loop when it finished playing? (Default to false)
* @return {Sound} The playing sound object.
*/
play: function (marker, position, volume, loop, forceRestart) {
@@ -366,6 +429,14 @@ Phaser.Sound.prototype = {
}
},
/**
* Restart the sound, or a marked section of it.
* @method restart
* @param {string} marker Assets key of the sound you want to play.
* @param {number} position The starting position
* @param {number} [volume] Volume of the sound you want to play.
* @param {bool} [loop] Loop when it finished playing? (Default to false)
*/
restart: function (marker, position, volume, loop) {
marker = marker || '';
@@ -377,6 +448,10 @@ Phaser.Sound.prototype = {
},
/**
* Pauses the sound
* @method pause
*/
pause: function () {
if (this.isPlaying && this._sound)
@@ -388,7 +463,10 @@ Phaser.Sound.prototype = {
}
},
/**
* Resumes the sound
* @method pause
*/
resume: function () {
if (this.paused && this._sound)
@@ -419,6 +497,7 @@ Phaser.Sound.prototype = {
/**
* Stop playing this sound.
* @method stop
*/
stop: function () {
@@ -470,13 +549,20 @@ Object.defineProperty(Phaser.Sound.prototype, "isDecoded", {
Object.defineProperty(Phaser.Sound.prototype, "mute", {
/**
* Mute sounds.
/**
* Mutes sound.
* @method mute
* @return {bool} whether or not the sound is muted
*/
get: function () {
return this._muted;
},
/**
* Mutes sound.
* @method mute
* @return {bool} whether or not the sound is muted
*/
set: function (value) {
value = value || null;
@@ -518,10 +604,18 @@ Object.defineProperty(Phaser.Sound.prototype, "mute", {
Object.defineProperty(Phaser.Sound.prototype, "volume", {
/**
* @method volume
* @return {number} The current volume. A value between 0 (silence) and 1 (full volume)
*/
get: function () {
return this._volume;
},
/**
* @method volume
* @return {number} Sets the current volume. A value between 0 (silence) and 1 (full volume)
*/
set: function (value) {
if (this.usingWebAudio)
+73 -11
View File
@@ -3,20 +3,47 @@
*
* @class SoundManager
* @constructor
* @param game {Phaser.Game} reference to the current game instance.
* @param {Phaser.Game} game reference to the current game instance.
*/
Phaser.SoundManager = function (game) {
/**
* A reference to the currently running Game.
* @property game
* @public
* @type {Phaser.Game}
*/
this.game = game;
this.onSoundDecode = new Phaser.Signal;
/**
* Boolean indicating whether the game is on "mute"
* @property _muted
* @private
* @type {bool}
*/
this._muted = false;
this._unlockSource = null;
/**
* The global audio volume. A value between 0 (silence) and 1 (full volume)
* @property _volume
* @private
* @type {number}
*/
this._volume = 1;
this._muted = false;
/**
* An array containing all the sounds
* @property _sounds
* @private
* @type {array}
*/
this._sounds = [];
this.context = null;
this.usingWebAudio = true;
this.usingAudioTag = false;
@@ -30,6 +57,10 @@ Phaser.SoundManager = function (game) {
Phaser.SoundManager.prototype = {
/**
* Initialises the sound manager
* @method boot
*/
boot: function () {
if (this.game.device.iOS && this.game.device.webAudio == false)
@@ -108,6 +139,10 @@ Phaser.SoundManager.prototype = {
},
/**
* Enables the audio, usually after the first touch
* @method unlock
*/
unlock: function () {
if (this.touchLocked == false)
@@ -138,6 +173,10 @@ Phaser.SoundManager.prototype = {
},
/**
* Stops all the sounds in the game
* @method stopAll
*/
stopAll: function () {
for (var i = 0; i < this._sounds.length; i++)
@@ -150,6 +189,10 @@ Phaser.SoundManager.prototype = {
},
/**
* Pauses all the sounds in the game
* @method pauseAll
*/
pauseAll: function () {
for (var i = 0; i < this._sounds.length; i++)
@@ -162,6 +205,10 @@ Phaser.SoundManager.prototype = {
},
/**
* resumes every sound in the game
* @method resumeAll
*/
resumeAll: function () {
for (var i = 0; i < this._sounds.length; i++)
@@ -176,8 +223,9 @@ Phaser.SoundManager.prototype = {
/**
* Decode a sound with its assets key.
* @method decode
* @param key {string} Assets key of the sound to be decoded.
* @param [sound] {Sound} its bufer will be set to decoded data.
* @param [sound] {Phaser.Sound} its bufer will be set to decoded data.
*/
decode: function (key, sound) {
@@ -205,6 +253,10 @@ Phaser.SoundManager.prototype = {
},
/**
* updates every sound in the game
* @method update
*/
update: function () {
if (this.touchLocked)
@@ -232,11 +284,10 @@ 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.
* @param {string} key Asset key for the sound.
* @param {number} volume Default value for the volume.
* @param {bool} loop Whether or not the sound will loop.
*/
add: function (key, volume, loop) {
volume = volume || 1;
@@ -258,6 +309,8 @@ Object.defineProperty(Phaser.SoundManager.prototype, "mute", {
/**
* A global audio mute toggle.
* @method mute
* @return {bool} whether or not the game is on "mute"
*/
get: function () {
@@ -265,6 +318,11 @@ Object.defineProperty(Phaser.SoundManager.prototype, "mute", {
},
/**
* Mute sounds.
* @method mute
* @return {bool} whether or not the game is on "mute"
*/
set: function (value) {
value = value || null;
@@ -316,14 +374,16 @@ Object.defineProperty(Phaser.SoundManager.prototype, "mute", {
}
}
}
},
}
enumerable: true,
configurable: true
});
Object.defineProperty(Phaser.SoundManager.prototype, "volume", {
/**
* @method volume
* @return {number} The global audio volume. A value between 0 (silence) and 1 (full volume)
*/
get: function () {
if (this.usingWebAudio)
@@ -338,7 +398,9 @@ Object.defineProperty(Phaser.SoundManager.prototype, "volume", {
},
/**
* The global audio volume. A value between 0 (silence) and 1 (full volume)
* Sets the global volume
* @method volume
* @return {number} The global audio volume. A value between 0 (silence) and 1 (full volume)
*/
set: function (value) {
+19 -1
View File
@@ -5,8 +5,22 @@
* @module Phaser.Canvas
*/
Phaser.Canvas = {
/**
* The Canvas class handles everything related to the <canvas> tag as a DOM Element, like styles, offset, aspect ratio
*
* @class Canvas
* @static
*/
Phaser.Canvas = {
/**
* Creates the <canvas> tag
*
* @method create
* @param {number} width The desired width
* @param {number} height The desired height
* @return {HTMLCanvasElement} the newly created <canvas> tag
*/
create: function (width, height) {
width = width || 256;
@@ -23,6 +37,10 @@ Phaser.Canvas = {
/**
* Get the DOM offset values of any given element
* @method getOffset
* @param {HTMLElement} element The targeted element that we want to retrieve the offset
* @param {Phaser.Point} [point] The point we want to take the x/y values of the offset
* @return point {Phaser.Point} A point objet with the offsetX and Y as its properties
*/
getOffset: function (element, point) {
+34 -4
View File
@@ -1,4 +1,15 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2013 Photon Storm Ltd.
* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License
* @module Phaser.Utils
*/
/**
*
* @class Utils
* @static
*/
Phaser.Utils = {
/**
@@ -6,6 +17,11 @@ Phaser.Utils = {
* http://www.webtoolkit.info/
* pad = the string to pad it out with (defaults to a space)
* dir = 1 (left), 2 (right), 3 (both)
* @method pad
* @param {string} str the target string
* @param {number} pad the string to pad it out with (defaults to a space)
* @param {number} len
* @param {number} [dir=3] the direction dir = 1 (left), 2 (right), 3 (both)
**/
pad: function (str, len, pad, dir) {
@@ -37,7 +53,11 @@ Phaser.Utils = {
},
// This is a slightly modified version of jQuery.isPlainObject
/**
* This is a slightly modified version of jQuery.isPlainObject
* @method isPlainObject
* @param {object} obj
*/
isPlainObject: function (obj) {
// Not plain objects:
@@ -67,11 +87,20 @@ Phaser.Utils = {
return true;
},
// deep, target, objects to copy to the target object
// This is a slightly modified version of jQuery.extend (http://api.jquery.com/jQuery.extend/)
// deep (boolean)
// target (object to add to)
// objects ... (objects to recurse and copy from)
/**
* This is a slightly modified version of jQuery.extend (http://api.jquery.com/jQuery.extend/)
* @method extend
* @param {bool} [deep] If true, the merge becomes recursive (aka. deep copy).
* @param {object} target The object to add to
* @param {object} objets Objects to recurse and copy from
*/
extend: function () {
var options, name, src, copy, copyIsArray, clone,
@@ -147,17 +176,18 @@ Phaser.Utils = {
// Global functions that PIXI needs
/**
/**
* Converts a hex color number to an [R, G, B] array
*
* @method HEXtoRGB
* @param hex {Number}
* @param {Number} hex
* @return {array}
*/
function HEXtoRGB(hex) {
return [(hex >> 16 & 0xFF) / 255, ( hex >> 8 & 0xFF) / 255, (hex & 0xFF)/ 255];
}
/**
/**
* A polyfill for Function.prototype.bind
*
* @method bind