diff --git a/src/core/sprites/Sprite.js b/src/core/sprites/Sprite.js index 28c6e9c..cf75bc4 100644 --- a/src/core/sprites/Sprite.js +++ b/src/core/sprites/Sprite.js @@ -206,7 +206,7 @@ }; /** - +* * Renders the object using the WebGL renderer * * @param renderer {WebGLRenderer} diff --git a/src/core/sprites/Sprite.js b/src/core/sprites/Sprite.js index 28c6e9c..cf75bc4 100644 --- a/src/core/sprites/Sprite.js +++ b/src/core/sprites/Sprite.js @@ -206,7 +206,7 @@ }; /** - +* * Renders the object using the WebGL renderer * * @param renderer {WebGLRenderer} diff --git a/src/core/textures/Texture.js b/src/core/textures/Texture.js index 69bfa08..740637b 100644 --- a/src/core/textures/Texture.js +++ b/src/core/textures/Texture.js @@ -9,6 +9,14 @@ * A texture stores the information that represents an image or part of an image. It cannot be added * to the display list directly. Instead use it as the texture for a Sprite. If no frame is provided then the whole image is used. * + * You can directly create a texture from an image and then reuse it multiple times like this : + * + * ```js + * var texture = PIXI.Texture.fromImage('assets/image.png'); + * var sprite1 = new PIXI.Sprite(texture); + * var sprite2 = new PIXI.Sprite(texture); + * ``` + * * @class * @mixes eventTarget * @namespace PIXI @@ -16,7 +24,7 @@ * @param [frame] {Rectangle} The rectangle frame of the texture to show * @param [crop] {Rectangle} The area of original texture * @param [trim] {Rectangle} Trimmed texture rectangle - * @param [rotate] {Rectangle} indicates if the texture should be rotated 90 degrees ( used by texture packer ) + * @param [rotate] {boolean} indicates whether the texture should be rotated by 90 degrees ( used by texture packer ) */ function Texture(baseTexture, frame, crop, trim, rotate) { @@ -107,10 +115,10 @@ this.crop = crop || frame;//new math.Rectangle(0, 0, 1, 1); /** - * The rotation value of the texture. + * Indicates whether the texture should be rotated by 90 degrees * * @private - * @member {number} + * @member {boolean} */ this.rotate = !!rotate; diff --git a/src/core/sprites/Sprite.js b/src/core/sprites/Sprite.js index 28c6e9c..cf75bc4 100644 --- a/src/core/sprites/Sprite.js +++ b/src/core/sprites/Sprite.js @@ -206,7 +206,7 @@ }; /** - +* * Renders the object using the WebGL renderer * * @param renderer {WebGLRenderer} diff --git a/src/core/textures/Texture.js b/src/core/textures/Texture.js index 69bfa08..740637b 100644 --- a/src/core/textures/Texture.js +++ b/src/core/textures/Texture.js @@ -9,6 +9,14 @@ * A texture stores the information that represents an image or part of an image. It cannot be added * to the display list directly. Instead use it as the texture for a Sprite. If no frame is provided then the whole image is used. * + * You can directly create a texture from an image and then reuse it multiple times like this : + * + * ```js + * var texture = PIXI.Texture.fromImage('assets/image.png'); + * var sprite1 = new PIXI.Sprite(texture); + * var sprite2 = new PIXI.Sprite(texture); + * ``` + * * @class * @mixes eventTarget * @namespace PIXI @@ -16,7 +24,7 @@ * @param [frame] {Rectangle} The rectangle frame of the texture to show * @param [crop] {Rectangle} The area of original texture * @param [trim] {Rectangle} Trimmed texture rectangle - * @param [rotate] {Rectangle} indicates if the texture should be rotated 90 degrees ( used by texture packer ) + * @param [rotate] {boolean} indicates whether the texture should be rotated by 90 degrees ( used by texture packer ) */ function Texture(baseTexture, frame, crop, trim, rotate) { @@ -107,10 +115,10 @@ this.crop = crop || frame;//new math.Rectangle(0, 0, 1, 1); /** - * The rotation value of the texture. + * Indicates whether the texture should be rotated by 90 degrees * * @private - * @member {number} + * @member {boolean} */ this.rotate = !!rotate; diff --git a/src/core/textures/VideoBaseTexture.js b/src/core/textures/VideoBaseTexture.js index 7ea8738..319d85c 100644 --- a/src/core/textures/VideoBaseTexture.js +++ b/src/core/textures/VideoBaseTexture.js @@ -4,6 +4,23 @@ /** * A texture of a [playing] Video. * + * Video base textures mimic Pixi BaseTexture.from.... method in their creation process. + * + * This can be used in several ways, such as: + * + * ```js + * var texture = PIXI.VideoBaseTexture.fromUrl('http://mydomain.com/video.mp4'); + * + * var texture = PIXI.VideoBaseTexture.fromUrl({ src: 'http://mydomain.com/video.mp4', mime: 'video/mp4' }); + * + * var texture = PIXI.VideoBaseTexture.fromUrls(['/video.webm', '/video.mp4']); + * + * var texture = PIXI.VideoBaseTexture.fromUrls([ + * { src: '/video.webm', mime: 'video/webm' }, + * { src: '/video.mp4', mime: 'video/mp4' } + * ]); + * ``` + * * See the ["deus" demo](http://www.goodboydigital.com/pixijs/examples/deus/). * * @class @@ -29,6 +46,12 @@ BaseTexture.call(this, source, scaleMode); + /** + * Should the base texture automatically update itself, set to true by default + * + * @member {boolean} + * @default true + */ this.autoUpdate = false; this._onUpdate = this._onUpdate.bind(this); @@ -51,6 +74,10 @@ VideoBaseTexture.prototype.constructor = VideoBaseTexture; module.exports = VideoBaseTexture; +/** + * The internal update loop of the video base texture, only runs when autoUpdate is set to true + * @private + */ VideoBaseTexture.prototype._onUpdate = function () { if (this.autoUpdate) @@ -60,6 +87,10 @@ } }; +/** + * Runs the update loop when the video is ready to play + * @private + */ VideoBaseTexture.prototype._onPlayStart = function () { if (!this.autoUpdate) @@ -69,11 +100,19 @@ } }; +/** + * Fired when a pause event is triggered, stops the update loop + * @private + */ VideoBaseTexture.prototype._onPlayStop = function () { this.autoUpdate = false; }; +/** + * Fired when the video is loaded and ready to play + * @private + */ VideoBaseTexture.prototype._onCanPlay = function () { this.hasLoaded = true; @@ -142,22 +181,8 @@ }; /** - * Mimic Pixi BaseTexture.from.... method. - * - * This can be used in a couple ways, such as: - * - * ```js - * var texture = PIXI.VideoBaseTexture.fromUrl('http://mydomain.com/video.mp4'); - * - * var texture = PIXI.VideoBaseTexture.fromUrl({ src: 'http://mydomain.com/video.mp4', mime: 'video/mp4' }); - * - * var texture = PIXI.VideoBaseTexture.fromUrls(['/video.webm', '/video.mp4']); - * - * var texture = PIXI.VideoBaseTexture.fromUrls([ - * { src: '/video.webm', mime: 'video/webm' }, - * { src: '/video.mp4', mime: 'video/mp4' } - * ]); - * ``` + * Helper function that creates a new BaseTexture based on the given video element. + * This BaseTexture can then be used to create a texture * * @alias fromUrls * @static diff --git a/src/core/sprites/Sprite.js b/src/core/sprites/Sprite.js index 28c6e9c..cf75bc4 100644 --- a/src/core/sprites/Sprite.js +++ b/src/core/sprites/Sprite.js @@ -206,7 +206,7 @@ }; /** - +* * Renders the object using the WebGL renderer * * @param renderer {WebGLRenderer} diff --git a/src/core/textures/Texture.js b/src/core/textures/Texture.js index 69bfa08..740637b 100644 --- a/src/core/textures/Texture.js +++ b/src/core/textures/Texture.js @@ -9,6 +9,14 @@ * A texture stores the information that represents an image or part of an image. It cannot be added * to the display list directly. Instead use it as the texture for a Sprite. If no frame is provided then the whole image is used. * + * You can directly create a texture from an image and then reuse it multiple times like this : + * + * ```js + * var texture = PIXI.Texture.fromImage('assets/image.png'); + * var sprite1 = new PIXI.Sprite(texture); + * var sprite2 = new PIXI.Sprite(texture); + * ``` + * * @class * @mixes eventTarget * @namespace PIXI @@ -16,7 +24,7 @@ * @param [frame] {Rectangle} The rectangle frame of the texture to show * @param [crop] {Rectangle} The area of original texture * @param [trim] {Rectangle} Trimmed texture rectangle - * @param [rotate] {Rectangle} indicates if the texture should be rotated 90 degrees ( used by texture packer ) + * @param [rotate] {boolean} indicates whether the texture should be rotated by 90 degrees ( used by texture packer ) */ function Texture(baseTexture, frame, crop, trim, rotate) { @@ -107,10 +115,10 @@ this.crop = crop || frame;//new math.Rectangle(0, 0, 1, 1); /** - * The rotation value of the texture. + * Indicates whether the texture should be rotated by 90 degrees * * @private - * @member {number} + * @member {boolean} */ this.rotate = !!rotate; diff --git a/src/core/textures/VideoBaseTexture.js b/src/core/textures/VideoBaseTexture.js index 7ea8738..319d85c 100644 --- a/src/core/textures/VideoBaseTexture.js +++ b/src/core/textures/VideoBaseTexture.js @@ -4,6 +4,23 @@ /** * A texture of a [playing] Video. * + * Video base textures mimic Pixi BaseTexture.from.... method in their creation process. + * + * This can be used in several ways, such as: + * + * ```js + * var texture = PIXI.VideoBaseTexture.fromUrl('http://mydomain.com/video.mp4'); + * + * var texture = PIXI.VideoBaseTexture.fromUrl({ src: 'http://mydomain.com/video.mp4', mime: 'video/mp4' }); + * + * var texture = PIXI.VideoBaseTexture.fromUrls(['/video.webm', '/video.mp4']); + * + * var texture = PIXI.VideoBaseTexture.fromUrls([ + * { src: '/video.webm', mime: 'video/webm' }, + * { src: '/video.mp4', mime: 'video/mp4' } + * ]); + * ``` + * * See the ["deus" demo](http://www.goodboydigital.com/pixijs/examples/deus/). * * @class @@ -29,6 +46,12 @@ BaseTexture.call(this, source, scaleMode); + /** + * Should the base texture automatically update itself, set to true by default + * + * @member {boolean} + * @default true + */ this.autoUpdate = false; this._onUpdate = this._onUpdate.bind(this); @@ -51,6 +74,10 @@ VideoBaseTexture.prototype.constructor = VideoBaseTexture; module.exports = VideoBaseTexture; +/** + * The internal update loop of the video base texture, only runs when autoUpdate is set to true + * @private + */ VideoBaseTexture.prototype._onUpdate = function () { if (this.autoUpdate) @@ -60,6 +87,10 @@ } }; +/** + * Runs the update loop when the video is ready to play + * @private + */ VideoBaseTexture.prototype._onPlayStart = function () { if (!this.autoUpdate) @@ -69,11 +100,19 @@ } }; +/** + * Fired when a pause event is triggered, stops the update loop + * @private + */ VideoBaseTexture.prototype._onPlayStop = function () { this.autoUpdate = false; }; +/** + * Fired when the video is loaded and ready to play + * @private + */ VideoBaseTexture.prototype._onCanPlay = function () { this.hasLoaded = true; @@ -142,22 +181,8 @@ }; /** - * Mimic Pixi BaseTexture.from.... method. - * - * This can be used in a couple ways, such as: - * - * ```js - * var texture = PIXI.VideoBaseTexture.fromUrl('http://mydomain.com/video.mp4'); - * - * var texture = PIXI.VideoBaseTexture.fromUrl({ src: 'http://mydomain.com/video.mp4', mime: 'video/mp4' }); - * - * var texture = PIXI.VideoBaseTexture.fromUrls(['/video.webm', '/video.mp4']); - * - * var texture = PIXI.VideoBaseTexture.fromUrls([ - * { src: '/video.webm', mime: 'video/webm' }, - * { src: '/video.mp4', mime: 'video/mp4' } - * ]); - * ``` + * Helper function that creates a new BaseTexture based on the given video element. + * This BaseTexture can then be used to create a texture * * @alias fromUrls * @static diff --git a/src/core/utils/Ticker.js b/src/core/utils/Ticker.js index 9beeddc..1016986 100644 --- a/src/core/utils/Ticker.js +++ b/src/core/utils/Ticker.js @@ -2,14 +2,36 @@ var eventTarget = require('./eventTarget'), EventData = require('./EventData'); +/** + * A Ticker class that runs the main update loop that other objects listen to + * + * @class + * + */ var Ticker = function() { this.updateBind = this.update.bind(this); + /** + * Whether or not this ticker runs + * + * @member {boolean} + */ this.active = false; this.eventData = new EventData( this, 'tick', { deltaTime:1 } ); + /** + * The deltaTime + * + * @member {number} + */ this.deltaTime = 1; + + /** + * The time between two frames + * + * @member {number} + */ this.timeElapsed = 0; this.lastTime = 0; @@ -19,10 +41,9 @@ this.start(); }; - - eventTarget.mixin(Ticker.prototype); + Ticker.prototype.start = function() { if(this.active) diff --git a/src/core/sprites/Sprite.js b/src/core/sprites/Sprite.js index 28c6e9c..cf75bc4 100644 --- a/src/core/sprites/Sprite.js +++ b/src/core/sprites/Sprite.js @@ -206,7 +206,7 @@ }; /** - +* * Renders the object using the WebGL renderer * * @param renderer {WebGLRenderer} diff --git a/src/core/textures/Texture.js b/src/core/textures/Texture.js index 69bfa08..740637b 100644 --- a/src/core/textures/Texture.js +++ b/src/core/textures/Texture.js @@ -9,6 +9,14 @@ * A texture stores the information that represents an image or part of an image. It cannot be added * to the display list directly. Instead use it as the texture for a Sprite. If no frame is provided then the whole image is used. * + * You can directly create a texture from an image and then reuse it multiple times like this : + * + * ```js + * var texture = PIXI.Texture.fromImage('assets/image.png'); + * var sprite1 = new PIXI.Sprite(texture); + * var sprite2 = new PIXI.Sprite(texture); + * ``` + * * @class * @mixes eventTarget * @namespace PIXI @@ -16,7 +24,7 @@ * @param [frame] {Rectangle} The rectangle frame of the texture to show * @param [crop] {Rectangle} The area of original texture * @param [trim] {Rectangle} Trimmed texture rectangle - * @param [rotate] {Rectangle} indicates if the texture should be rotated 90 degrees ( used by texture packer ) + * @param [rotate] {boolean} indicates whether the texture should be rotated by 90 degrees ( used by texture packer ) */ function Texture(baseTexture, frame, crop, trim, rotate) { @@ -107,10 +115,10 @@ this.crop = crop || frame;//new math.Rectangle(0, 0, 1, 1); /** - * The rotation value of the texture. + * Indicates whether the texture should be rotated by 90 degrees * * @private - * @member {number} + * @member {boolean} */ this.rotate = !!rotate; diff --git a/src/core/textures/VideoBaseTexture.js b/src/core/textures/VideoBaseTexture.js index 7ea8738..319d85c 100644 --- a/src/core/textures/VideoBaseTexture.js +++ b/src/core/textures/VideoBaseTexture.js @@ -4,6 +4,23 @@ /** * A texture of a [playing] Video. * + * Video base textures mimic Pixi BaseTexture.from.... method in their creation process. + * + * This can be used in several ways, such as: + * + * ```js + * var texture = PIXI.VideoBaseTexture.fromUrl('http://mydomain.com/video.mp4'); + * + * var texture = PIXI.VideoBaseTexture.fromUrl({ src: 'http://mydomain.com/video.mp4', mime: 'video/mp4' }); + * + * var texture = PIXI.VideoBaseTexture.fromUrls(['/video.webm', '/video.mp4']); + * + * var texture = PIXI.VideoBaseTexture.fromUrls([ + * { src: '/video.webm', mime: 'video/webm' }, + * { src: '/video.mp4', mime: 'video/mp4' } + * ]); + * ``` + * * See the ["deus" demo](http://www.goodboydigital.com/pixijs/examples/deus/). * * @class @@ -29,6 +46,12 @@ BaseTexture.call(this, source, scaleMode); + /** + * Should the base texture automatically update itself, set to true by default + * + * @member {boolean} + * @default true + */ this.autoUpdate = false; this._onUpdate = this._onUpdate.bind(this); @@ -51,6 +74,10 @@ VideoBaseTexture.prototype.constructor = VideoBaseTexture; module.exports = VideoBaseTexture; +/** + * The internal update loop of the video base texture, only runs when autoUpdate is set to true + * @private + */ VideoBaseTexture.prototype._onUpdate = function () { if (this.autoUpdate) @@ -60,6 +87,10 @@ } }; +/** + * Runs the update loop when the video is ready to play + * @private + */ VideoBaseTexture.prototype._onPlayStart = function () { if (!this.autoUpdate) @@ -69,11 +100,19 @@ } }; +/** + * Fired when a pause event is triggered, stops the update loop + * @private + */ VideoBaseTexture.prototype._onPlayStop = function () { this.autoUpdate = false; }; +/** + * Fired when the video is loaded and ready to play + * @private + */ VideoBaseTexture.prototype._onCanPlay = function () { this.hasLoaded = true; @@ -142,22 +181,8 @@ }; /** - * Mimic Pixi BaseTexture.from.... method. - * - * This can be used in a couple ways, such as: - * - * ```js - * var texture = PIXI.VideoBaseTexture.fromUrl('http://mydomain.com/video.mp4'); - * - * var texture = PIXI.VideoBaseTexture.fromUrl({ src: 'http://mydomain.com/video.mp4', mime: 'video/mp4' }); - * - * var texture = PIXI.VideoBaseTexture.fromUrls(['/video.webm', '/video.mp4']); - * - * var texture = PIXI.VideoBaseTexture.fromUrls([ - * { src: '/video.webm', mime: 'video/webm' }, - * { src: '/video.mp4', mime: 'video/mp4' } - * ]); - * ``` + * Helper function that creates a new BaseTexture based on the given video element. + * This BaseTexture can then be used to create a texture * * @alias fromUrls * @static diff --git a/src/core/utils/Ticker.js b/src/core/utils/Ticker.js index 9beeddc..1016986 100644 --- a/src/core/utils/Ticker.js +++ b/src/core/utils/Ticker.js @@ -2,14 +2,36 @@ var eventTarget = require('./eventTarget'), EventData = require('./EventData'); +/** + * A Ticker class that runs the main update loop that other objects listen to + * + * @class + * + */ var Ticker = function() { this.updateBind = this.update.bind(this); + /** + * Whether or not this ticker runs + * + * @member {boolean} + */ this.active = false; this.eventData = new EventData( this, 'tick', { deltaTime:1 } ); + /** + * The deltaTime + * + * @member {number} + */ this.deltaTime = 1; + + /** + * The time between two frames + * + * @member {number} + */ this.timeElapsed = 0; this.lastTime = 0; @@ -19,10 +41,9 @@ this.start(); }; - - eventTarget.mixin(Ticker.prototype); + Ticker.prototype.start = function() { if(this.active) diff --git a/src/core/utils/index.js b/src/core/utils/index.js index 8fa3e2f..70eb1ae 100644 --- a/src/core/utils/index.js +++ b/src/core/utils/index.js @@ -138,8 +138,7 @@ * used by spritesheets and image urls * TODO make this smarter! * - * @param width {number} - * @param height {number} + * @param url {string} the image path * @return {boolean} */ getResolutionOfUrl: function (url) diff --git a/src/core/sprites/Sprite.js b/src/core/sprites/Sprite.js index 28c6e9c..cf75bc4 100644 --- a/src/core/sprites/Sprite.js +++ b/src/core/sprites/Sprite.js @@ -206,7 +206,7 @@ }; /** - +* * Renders the object using the WebGL renderer * * @param renderer {WebGLRenderer} diff --git a/src/core/textures/Texture.js b/src/core/textures/Texture.js index 69bfa08..740637b 100644 --- a/src/core/textures/Texture.js +++ b/src/core/textures/Texture.js @@ -9,6 +9,14 @@ * A texture stores the information that represents an image or part of an image. It cannot be added * to the display list directly. Instead use it as the texture for a Sprite. If no frame is provided then the whole image is used. * + * You can directly create a texture from an image and then reuse it multiple times like this : + * + * ```js + * var texture = PIXI.Texture.fromImage('assets/image.png'); + * var sprite1 = new PIXI.Sprite(texture); + * var sprite2 = new PIXI.Sprite(texture); + * ``` + * * @class * @mixes eventTarget * @namespace PIXI @@ -16,7 +24,7 @@ * @param [frame] {Rectangle} The rectangle frame of the texture to show * @param [crop] {Rectangle} The area of original texture * @param [trim] {Rectangle} Trimmed texture rectangle - * @param [rotate] {Rectangle} indicates if the texture should be rotated 90 degrees ( used by texture packer ) + * @param [rotate] {boolean} indicates whether the texture should be rotated by 90 degrees ( used by texture packer ) */ function Texture(baseTexture, frame, crop, trim, rotate) { @@ -107,10 +115,10 @@ this.crop = crop || frame;//new math.Rectangle(0, 0, 1, 1); /** - * The rotation value of the texture. + * Indicates whether the texture should be rotated by 90 degrees * * @private - * @member {number} + * @member {boolean} */ this.rotate = !!rotate; diff --git a/src/core/textures/VideoBaseTexture.js b/src/core/textures/VideoBaseTexture.js index 7ea8738..319d85c 100644 --- a/src/core/textures/VideoBaseTexture.js +++ b/src/core/textures/VideoBaseTexture.js @@ -4,6 +4,23 @@ /** * A texture of a [playing] Video. * + * Video base textures mimic Pixi BaseTexture.from.... method in their creation process. + * + * This can be used in several ways, such as: + * + * ```js + * var texture = PIXI.VideoBaseTexture.fromUrl('http://mydomain.com/video.mp4'); + * + * var texture = PIXI.VideoBaseTexture.fromUrl({ src: 'http://mydomain.com/video.mp4', mime: 'video/mp4' }); + * + * var texture = PIXI.VideoBaseTexture.fromUrls(['/video.webm', '/video.mp4']); + * + * var texture = PIXI.VideoBaseTexture.fromUrls([ + * { src: '/video.webm', mime: 'video/webm' }, + * { src: '/video.mp4', mime: 'video/mp4' } + * ]); + * ``` + * * See the ["deus" demo](http://www.goodboydigital.com/pixijs/examples/deus/). * * @class @@ -29,6 +46,12 @@ BaseTexture.call(this, source, scaleMode); + /** + * Should the base texture automatically update itself, set to true by default + * + * @member {boolean} + * @default true + */ this.autoUpdate = false; this._onUpdate = this._onUpdate.bind(this); @@ -51,6 +74,10 @@ VideoBaseTexture.prototype.constructor = VideoBaseTexture; module.exports = VideoBaseTexture; +/** + * The internal update loop of the video base texture, only runs when autoUpdate is set to true + * @private + */ VideoBaseTexture.prototype._onUpdate = function () { if (this.autoUpdate) @@ -60,6 +87,10 @@ } }; +/** + * Runs the update loop when the video is ready to play + * @private + */ VideoBaseTexture.prototype._onPlayStart = function () { if (!this.autoUpdate) @@ -69,11 +100,19 @@ } }; +/** + * Fired when a pause event is triggered, stops the update loop + * @private + */ VideoBaseTexture.prototype._onPlayStop = function () { this.autoUpdate = false; }; +/** + * Fired when the video is loaded and ready to play + * @private + */ VideoBaseTexture.prototype._onCanPlay = function () { this.hasLoaded = true; @@ -142,22 +181,8 @@ }; /** - * Mimic Pixi BaseTexture.from.... method. - * - * This can be used in a couple ways, such as: - * - * ```js - * var texture = PIXI.VideoBaseTexture.fromUrl('http://mydomain.com/video.mp4'); - * - * var texture = PIXI.VideoBaseTexture.fromUrl({ src: 'http://mydomain.com/video.mp4', mime: 'video/mp4' }); - * - * var texture = PIXI.VideoBaseTexture.fromUrls(['/video.webm', '/video.mp4']); - * - * var texture = PIXI.VideoBaseTexture.fromUrls([ - * { src: '/video.webm', mime: 'video/webm' }, - * { src: '/video.mp4', mime: 'video/mp4' } - * ]); - * ``` + * Helper function that creates a new BaseTexture based on the given video element. + * This BaseTexture can then be used to create a texture * * @alias fromUrls * @static diff --git a/src/core/utils/Ticker.js b/src/core/utils/Ticker.js index 9beeddc..1016986 100644 --- a/src/core/utils/Ticker.js +++ b/src/core/utils/Ticker.js @@ -2,14 +2,36 @@ var eventTarget = require('./eventTarget'), EventData = require('./EventData'); +/** + * A Ticker class that runs the main update loop that other objects listen to + * + * @class + * + */ var Ticker = function() { this.updateBind = this.update.bind(this); + /** + * Whether or not this ticker runs + * + * @member {boolean} + */ this.active = false; this.eventData = new EventData( this, 'tick', { deltaTime:1 } ); + /** + * The deltaTime + * + * @member {number} + */ this.deltaTime = 1; + + /** + * The time between two frames + * + * @member {number} + */ this.timeElapsed = 0; this.lastTime = 0; @@ -19,10 +41,9 @@ this.start(); }; - - eventTarget.mixin(Ticker.prototype); + Ticker.prototype.start = function() { if(this.active) diff --git a/src/core/utils/index.js b/src/core/utils/index.js index 8fa3e2f..70eb1ae 100644 --- a/src/core/utils/index.js +++ b/src/core/utils/index.js @@ -138,8 +138,7 @@ * used by spritesheets and image urls * TODO make this smarter! * - * @param width {number} - * @param height {number} + * @param url {string} the image path * @return {boolean} */ getResolutionOfUrl: function (url) diff --git a/src/core/utils/pluginTarget.js b/src/core/utils/pluginTarget.js index 7969d02..3157f89 100644 --- a/src/core/utils/pluginTarget.js +++ b/src/core/utils/pluginTarget.js @@ -13,11 +13,21 @@ { obj.__plugins = {}; + /** + * Adds a plugin to an object + * + * @param pluginName {string} The events that should be listed. + * @param ctor {Object} ?? @alvin + */ obj.registerPlugin = function (pluginName, ctor) { obj.__plugins[pluginName] = ctor; }; + /** + * Instantiates all the plugins of this object + * + */ obj.prototype.initPlugins = function () { this.plugins = this.plugins || {}; @@ -28,6 +38,10 @@ } }; + /** + * Removes all the plugins of this object + * + */ obj.prototype.destroyPlugins = function () { for (var o in this.plugins) diff --git a/src/core/sprites/Sprite.js b/src/core/sprites/Sprite.js index 28c6e9c..cf75bc4 100644 --- a/src/core/sprites/Sprite.js +++ b/src/core/sprites/Sprite.js @@ -206,7 +206,7 @@ }; /** - +* * Renders the object using the WebGL renderer * * @param renderer {WebGLRenderer} diff --git a/src/core/textures/Texture.js b/src/core/textures/Texture.js index 69bfa08..740637b 100644 --- a/src/core/textures/Texture.js +++ b/src/core/textures/Texture.js @@ -9,6 +9,14 @@ * A texture stores the information that represents an image or part of an image. It cannot be added * to the display list directly. Instead use it as the texture for a Sprite. If no frame is provided then the whole image is used. * + * You can directly create a texture from an image and then reuse it multiple times like this : + * + * ```js + * var texture = PIXI.Texture.fromImage('assets/image.png'); + * var sprite1 = new PIXI.Sprite(texture); + * var sprite2 = new PIXI.Sprite(texture); + * ``` + * * @class * @mixes eventTarget * @namespace PIXI @@ -16,7 +24,7 @@ * @param [frame] {Rectangle} The rectangle frame of the texture to show * @param [crop] {Rectangle} The area of original texture * @param [trim] {Rectangle} Trimmed texture rectangle - * @param [rotate] {Rectangle} indicates if the texture should be rotated 90 degrees ( used by texture packer ) + * @param [rotate] {boolean} indicates whether the texture should be rotated by 90 degrees ( used by texture packer ) */ function Texture(baseTexture, frame, crop, trim, rotate) { @@ -107,10 +115,10 @@ this.crop = crop || frame;//new math.Rectangle(0, 0, 1, 1); /** - * The rotation value of the texture. + * Indicates whether the texture should be rotated by 90 degrees * * @private - * @member {number} + * @member {boolean} */ this.rotate = !!rotate; diff --git a/src/core/textures/VideoBaseTexture.js b/src/core/textures/VideoBaseTexture.js index 7ea8738..319d85c 100644 --- a/src/core/textures/VideoBaseTexture.js +++ b/src/core/textures/VideoBaseTexture.js @@ -4,6 +4,23 @@ /** * A texture of a [playing] Video. * + * Video base textures mimic Pixi BaseTexture.from.... method in their creation process. + * + * This can be used in several ways, such as: + * + * ```js + * var texture = PIXI.VideoBaseTexture.fromUrl('http://mydomain.com/video.mp4'); + * + * var texture = PIXI.VideoBaseTexture.fromUrl({ src: 'http://mydomain.com/video.mp4', mime: 'video/mp4' }); + * + * var texture = PIXI.VideoBaseTexture.fromUrls(['/video.webm', '/video.mp4']); + * + * var texture = PIXI.VideoBaseTexture.fromUrls([ + * { src: '/video.webm', mime: 'video/webm' }, + * { src: '/video.mp4', mime: 'video/mp4' } + * ]); + * ``` + * * See the ["deus" demo](http://www.goodboydigital.com/pixijs/examples/deus/). * * @class @@ -29,6 +46,12 @@ BaseTexture.call(this, source, scaleMode); + /** + * Should the base texture automatically update itself, set to true by default + * + * @member {boolean} + * @default true + */ this.autoUpdate = false; this._onUpdate = this._onUpdate.bind(this); @@ -51,6 +74,10 @@ VideoBaseTexture.prototype.constructor = VideoBaseTexture; module.exports = VideoBaseTexture; +/** + * The internal update loop of the video base texture, only runs when autoUpdate is set to true + * @private + */ VideoBaseTexture.prototype._onUpdate = function () { if (this.autoUpdate) @@ -60,6 +87,10 @@ } }; +/** + * Runs the update loop when the video is ready to play + * @private + */ VideoBaseTexture.prototype._onPlayStart = function () { if (!this.autoUpdate) @@ -69,11 +100,19 @@ } }; +/** + * Fired when a pause event is triggered, stops the update loop + * @private + */ VideoBaseTexture.prototype._onPlayStop = function () { this.autoUpdate = false; }; +/** + * Fired when the video is loaded and ready to play + * @private + */ VideoBaseTexture.prototype._onCanPlay = function () { this.hasLoaded = true; @@ -142,22 +181,8 @@ }; /** - * Mimic Pixi BaseTexture.from.... method. - * - * This can be used in a couple ways, such as: - * - * ```js - * var texture = PIXI.VideoBaseTexture.fromUrl('http://mydomain.com/video.mp4'); - * - * var texture = PIXI.VideoBaseTexture.fromUrl({ src: 'http://mydomain.com/video.mp4', mime: 'video/mp4' }); - * - * var texture = PIXI.VideoBaseTexture.fromUrls(['/video.webm', '/video.mp4']); - * - * var texture = PIXI.VideoBaseTexture.fromUrls([ - * { src: '/video.webm', mime: 'video/webm' }, - * { src: '/video.mp4', mime: 'video/mp4' } - * ]); - * ``` + * Helper function that creates a new BaseTexture based on the given video element. + * This BaseTexture can then be used to create a texture * * @alias fromUrls * @static diff --git a/src/core/utils/Ticker.js b/src/core/utils/Ticker.js index 9beeddc..1016986 100644 --- a/src/core/utils/Ticker.js +++ b/src/core/utils/Ticker.js @@ -2,14 +2,36 @@ var eventTarget = require('./eventTarget'), EventData = require('./EventData'); +/** + * A Ticker class that runs the main update loop that other objects listen to + * + * @class + * + */ var Ticker = function() { this.updateBind = this.update.bind(this); + /** + * Whether or not this ticker runs + * + * @member {boolean} + */ this.active = false; this.eventData = new EventData( this, 'tick', { deltaTime:1 } ); + /** + * The deltaTime + * + * @member {number} + */ this.deltaTime = 1; + + /** + * The time between two frames + * + * @member {number} + */ this.timeElapsed = 0; this.lastTime = 0; @@ -19,10 +41,9 @@ this.start(); }; - - eventTarget.mixin(Ticker.prototype); + Ticker.prototype.start = function() { if(this.active) diff --git a/src/core/utils/index.js b/src/core/utils/index.js index 8fa3e2f..70eb1ae 100644 --- a/src/core/utils/index.js +++ b/src/core/utils/index.js @@ -138,8 +138,7 @@ * used by spritesheets and image urls * TODO make this smarter! * - * @param width {number} - * @param height {number} + * @param url {string} the image path * @return {boolean} */ getResolutionOfUrl: function (url) diff --git a/src/core/utils/pluginTarget.js b/src/core/utils/pluginTarget.js index 7969d02..3157f89 100644 --- a/src/core/utils/pluginTarget.js +++ b/src/core/utils/pluginTarget.js @@ -13,11 +13,21 @@ { obj.__plugins = {}; + /** + * Adds a plugin to an object + * + * @param pluginName {string} The events that should be listed. + * @param ctor {Object} ?? @alvin + */ obj.registerPlugin = function (pluginName, ctor) { obj.__plugins[pluginName] = ctor; }; + /** + * Instantiates all the plugins of this object + * + */ obj.prototype.initPlugins = function () { this.plugins = this.plugins || {}; @@ -28,6 +38,10 @@ } }; + /** + * Removes all the plugins of this object + * + */ obj.prototype.destroyPlugins = function () { for (var o in this.plugins) diff --git a/src/extras/MovieClip.js b/src/extras/MovieClip.js index a297dcd..5e93f00 100644 --- a/src/extras/MovieClip.js +++ b/src/extras/MovieClip.js @@ -148,7 +148,7 @@ this.currentFrame = frameNumber; - var round = Math.round(this.currentFrame); + var round = Math.floor(this.currentFrame); this.texture = this._textures[round % this._textures.length]; }; @@ -165,7 +165,6 @@ /* * Updates the object transform for rendering - * * @private */ MovieClip.prototype.update = function ( event )