diff --git a/src/core/index.js b/src/core/index.js index b67c15a..dcbf19d 100644 --- a/src/core/index.js +++ b/src/core/index.js @@ -80,16 +80,6 @@ } return new core.CanvasRenderer(width, height, options); - }, - - Stage: function () - { - window.console.warn("You don't need to use a PIXI Stage any more, you can simply render any container"); - return new core.Container(); - }, - - SpriteBatch: function () { - window.console.warn("SpriteBatch doesn't exist any more, please use the new ParticleContainer instead"); } }; diff --git a/src/core/index.js b/src/core/index.js index b67c15a..dcbf19d 100644 --- a/src/core/index.js +++ b/src/core/index.js @@ -80,16 +80,6 @@ } return new core.CanvasRenderer(width, height, options); - }, - - Stage: function () - { - window.console.warn("You don't need to use a PIXI Stage any more, you can simply render any container"); - return new core.Container(); - }, - - SpriteBatch: function () { - window.console.warn("SpriteBatch doesn't exist any more, please use the new ParticleContainer instead"); } }; diff --git a/src/core/sprites/Sprite.js b/src/core/sprites/Sprite.js index e3c6b54..96e06db 100644 --- a/src/core/sprites/Sprite.js +++ b/src/core/sprites/Sprite.js @@ -510,11 +510,6 @@ } }; -Sprite.prototype.setTexture = function () -{ - window.console.warn('setTexture is now deprecated, please use the texture property, e.g : sprite.texture = texture; '); -}; - // some helper functions.. /** diff --git a/src/core/index.js b/src/core/index.js index b67c15a..dcbf19d 100644 --- a/src/core/index.js +++ b/src/core/index.js @@ -80,16 +80,6 @@ } return new core.CanvasRenderer(width, height, options); - }, - - Stage: function () - { - window.console.warn("You don't need to use a PIXI Stage any more, you can simply render any container"); - return new core.Container(); - }, - - SpriteBatch: function () { - window.console.warn("SpriteBatch doesn't exist any more, please use the new ParticleContainer instead"); } }; diff --git a/src/core/sprites/Sprite.js b/src/core/sprites/Sprite.js index e3c6b54..96e06db 100644 --- a/src/core/sprites/Sprite.js +++ b/src/core/sprites/Sprite.js @@ -510,11 +510,6 @@ } }; -Sprite.prototype.setTexture = function () -{ - window.console.warn('setTexture is now deprecated, please use the texture property, e.g : sprite.texture = texture; '); -}; - // some helper functions.. /** diff --git a/src/deprecation.js b/src/deprecation.js new file mode 100644 index 0000000..60d052f --- /dev/null +++ b/src/deprecation.js @@ -0,0 +1,37 @@ +var core = require('./core'), + text = require('./text'); + +core.Stage = function () +{ + window.console.warn("You don't need to use a PIXI Stage any more, you can simply render any container."); + return new core.Container(); +}; + +core.SpriteBatch = function () +{ + window.console.warn("SpriteBatch doesn't exist any more, please use the new ParticleContainer instead."); +}; + +core.AssetsLoader = function () { + window.console.warn("The loader system was overhauled in pixi v3, please see the new PIXI.Loader class."); +}; + +core.Sprite.prototype.setTexture = function (texture) +{ + this.texture = texture; + window.console.warn("setTexture is now deprecated, please use the texture property, e.g : sprite.texture = texture;"); +}; + +text.BitmapText.prototype.setText = function (text) +{ + this.text = text; + window.console.warn("setText is now deprecated, please use the text property, e.g : myBitmapText.text = 'my text';"); +}; + +text.Text.prototype.setText = function (text) +{ + this.text = text; + window.console.warn("setText is now deprecated, please use the text property, e.g : myText.text = 'my text';"); +}; + +module.exports = {}; diff --git a/src/core/index.js b/src/core/index.js index b67c15a..dcbf19d 100644 --- a/src/core/index.js +++ b/src/core/index.js @@ -80,16 +80,6 @@ } return new core.CanvasRenderer(width, height, options); - }, - - Stage: function () - { - window.console.warn("You don't need to use a PIXI Stage any more, you can simply render any container"); - return new core.Container(); - }, - - SpriteBatch: function () { - window.console.warn("SpriteBatch doesn't exist any more, please use the new ParticleContainer instead"); } }; diff --git a/src/core/sprites/Sprite.js b/src/core/sprites/Sprite.js index e3c6b54..96e06db 100644 --- a/src/core/sprites/Sprite.js +++ b/src/core/sprites/Sprite.js @@ -510,11 +510,6 @@ } }; -Sprite.prototype.setTexture = function () -{ - window.console.warn('setTexture is now deprecated, please use the texture property, e.g : sprite.texture = texture; '); -}; - // some helper functions.. /** diff --git a/src/deprecation.js b/src/deprecation.js new file mode 100644 index 0000000..60d052f --- /dev/null +++ b/src/deprecation.js @@ -0,0 +1,37 @@ +var core = require('./core'), + text = require('./text'); + +core.Stage = function () +{ + window.console.warn("You don't need to use a PIXI Stage any more, you can simply render any container."); + return new core.Container(); +}; + +core.SpriteBatch = function () +{ + window.console.warn("SpriteBatch doesn't exist any more, please use the new ParticleContainer instead."); +}; + +core.AssetsLoader = function () { + window.console.warn("The loader system was overhauled in pixi v3, please see the new PIXI.Loader class."); +}; + +core.Sprite.prototype.setTexture = function (texture) +{ + this.texture = texture; + window.console.warn("setTexture is now deprecated, please use the texture property, e.g : sprite.texture = texture;"); +}; + +text.BitmapText.prototype.setText = function (text) +{ + this.text = text; + window.console.warn("setText is now deprecated, please use the text property, e.g : myBitmapText.text = 'my text';"); +}; + +text.Text.prototype.setText = function (text) +{ + this.text = text; + window.console.warn("setText is now deprecated, please use the text property, e.g : myText.text = 'my text';"); +}; + +module.exports = {}; diff --git a/src/extras/cacheAsBitmap.js b/src/extras/cacheAsBitmap.js index 20f2b99..9fe88df 100644 --- a/src/extras/cacheAsBitmap.js +++ b/src/extras/cacheAsBitmap.js @@ -17,6 +17,15 @@ Object.defineProperties(DisplayObject.prototype, { + + /** + * Set this to true if you want this display object to be cached as a bitmap. + * This basically takes a snap shot of the display object as it is at that moment. It can provide a performance benefit for complex static displayObjects. + * To remove simply set this property to 'null' + * + * @member {boolean} + * @memberof DisplayObject# + */ cacheAsBitmap: { get: function () { @@ -60,12 +69,17 @@ this.getBounds = this._originalGetBounds; this.updateTransform = this._originalUpdateTransform; - this.containsPoint = this._originalContainesPoint; + this.containsPoint = this._originalContainsPoint; } } } }); - +/** +* Renders a cached version of the sprite with WebGL +* +* @param renderer {WebGLRenderer} the WebGL renderer +* @private +*/ DisplayObject.prototype._renderCachedWebGL = function(renderer) { this._initCachedDisplayObject( renderer ); @@ -76,6 +90,12 @@ renderer.plugins.sprite.render( this._cachedSprite ); }; +/** +* Prepares the WebGL renderer to cache the sprite +* +* @param renderer {WebGLRenderer} the WebGL renderer +* @private +*/ DisplayObject.prototype._initCachedDisplayObject = function( renderer ) { if(this._cachedSprite) @@ -83,6 +103,7 @@ return; } + // first we flush anything left in the renderer (otherwise it would get rendered to the cached texture) renderer.currentRenderer.flush(); //this.filters= []; @@ -117,7 +138,7 @@ this.renderWebGL = this._renderCachedWebGL; this.updateTransform = this.displayObjectUpdateTransform; - this.getBounds = this._getCahcedBounds; + this.getBounds = this._getCachedBounds; // create our cached sprite @@ -130,7 +151,12 @@ this.containsPoint = this._cachedSprite.containsPoint.bind(this._cachedSprite); }; - +/** +* Renders a cached version of the sprite with canvas +* +* @param renderer {CanvasRenderer} the Canvas renderer +* @private +*/ DisplayObject.prototype._renderCachedCanvas = function(renderer) { this._initCachedDisplayObjectCanvas( renderer ); @@ -141,6 +167,12 @@ }; //TODO this can be the same as the webGL verison.. will need to do a little tweaking first though.. +/** +* Prepares the Canvas renderer to cache the sprite +* +* @param renderer {CanvasRenderer} the Canvas renderer +* @private +*/ DisplayObject.prototype._initCachedDisplayObjectCanvas = function( renderer ) { if(this._cachedSprite) @@ -171,7 +203,7 @@ this.renderCanvas = this._renderCachedCanvas; this.updateTransform = this.displayObjectUpdateTransform; - this.getBounds = this._getCahcedBounds; + this.getBounds = this._getCachedBounds; // create our cached sprite @@ -182,13 +214,23 @@ this.hitTest = this._cachedSprite.hitTest.bind(this._cachedSprite); }; -DisplayObject.prototype._getCahcedBounds = function() +/** +* Calculates the bounds of the cached sprite +* +* @private +*/ +DisplayObject.prototype._getCachedBounds = function() { this._cachedSprite._currentBounds = null; return this._cachedSprite.getBounds(); }; +/** +* Destroys the cached sprite. +* +* @private +*/ DisplayObject.prototype._destroyCachedDisplayObject = function() { this._cachedSprite._texture.destroy(); diff --git a/src/core/index.js b/src/core/index.js index b67c15a..dcbf19d 100644 --- a/src/core/index.js +++ b/src/core/index.js @@ -80,16 +80,6 @@ } return new core.CanvasRenderer(width, height, options); - }, - - Stage: function () - { - window.console.warn("You don't need to use a PIXI Stage any more, you can simply render any container"); - return new core.Container(); - }, - - SpriteBatch: function () { - window.console.warn("SpriteBatch doesn't exist any more, please use the new ParticleContainer instead"); } }; diff --git a/src/core/sprites/Sprite.js b/src/core/sprites/Sprite.js index e3c6b54..96e06db 100644 --- a/src/core/sprites/Sprite.js +++ b/src/core/sprites/Sprite.js @@ -510,11 +510,6 @@ } }; -Sprite.prototype.setTexture = function () -{ - window.console.warn('setTexture is now deprecated, please use the texture property, e.g : sprite.texture = texture; '); -}; - // some helper functions.. /** diff --git a/src/deprecation.js b/src/deprecation.js new file mode 100644 index 0000000..60d052f --- /dev/null +++ b/src/deprecation.js @@ -0,0 +1,37 @@ +var core = require('./core'), + text = require('./text'); + +core.Stage = function () +{ + window.console.warn("You don't need to use a PIXI Stage any more, you can simply render any container."); + return new core.Container(); +}; + +core.SpriteBatch = function () +{ + window.console.warn("SpriteBatch doesn't exist any more, please use the new ParticleContainer instead."); +}; + +core.AssetsLoader = function () { + window.console.warn("The loader system was overhauled in pixi v3, please see the new PIXI.Loader class."); +}; + +core.Sprite.prototype.setTexture = function (texture) +{ + this.texture = texture; + window.console.warn("setTexture is now deprecated, please use the texture property, e.g : sprite.texture = texture;"); +}; + +text.BitmapText.prototype.setText = function (text) +{ + this.text = text; + window.console.warn("setText is now deprecated, please use the text property, e.g : myBitmapText.text = 'my text';"); +}; + +text.Text.prototype.setText = function (text) +{ + this.text = text; + window.console.warn("setText is now deprecated, please use the text property, e.g : myText.text = 'my text';"); +}; + +module.exports = {}; diff --git a/src/extras/cacheAsBitmap.js b/src/extras/cacheAsBitmap.js index 20f2b99..9fe88df 100644 --- a/src/extras/cacheAsBitmap.js +++ b/src/extras/cacheAsBitmap.js @@ -17,6 +17,15 @@ Object.defineProperties(DisplayObject.prototype, { + + /** + * Set this to true if you want this display object to be cached as a bitmap. + * This basically takes a snap shot of the display object as it is at that moment. It can provide a performance benefit for complex static displayObjects. + * To remove simply set this property to 'null' + * + * @member {boolean} + * @memberof DisplayObject# + */ cacheAsBitmap: { get: function () { @@ -60,12 +69,17 @@ this.getBounds = this._originalGetBounds; this.updateTransform = this._originalUpdateTransform; - this.containsPoint = this._originalContainesPoint; + this.containsPoint = this._originalContainsPoint; } } } }); - +/** +* Renders a cached version of the sprite with WebGL +* +* @param renderer {WebGLRenderer} the WebGL renderer +* @private +*/ DisplayObject.prototype._renderCachedWebGL = function(renderer) { this._initCachedDisplayObject( renderer ); @@ -76,6 +90,12 @@ renderer.plugins.sprite.render( this._cachedSprite ); }; +/** +* Prepares the WebGL renderer to cache the sprite +* +* @param renderer {WebGLRenderer} the WebGL renderer +* @private +*/ DisplayObject.prototype._initCachedDisplayObject = function( renderer ) { if(this._cachedSprite) @@ -83,6 +103,7 @@ return; } + // first we flush anything left in the renderer (otherwise it would get rendered to the cached texture) renderer.currentRenderer.flush(); //this.filters= []; @@ -117,7 +138,7 @@ this.renderWebGL = this._renderCachedWebGL; this.updateTransform = this.displayObjectUpdateTransform; - this.getBounds = this._getCahcedBounds; + this.getBounds = this._getCachedBounds; // create our cached sprite @@ -130,7 +151,12 @@ this.containsPoint = this._cachedSprite.containsPoint.bind(this._cachedSprite); }; - +/** +* Renders a cached version of the sprite with canvas +* +* @param renderer {CanvasRenderer} the Canvas renderer +* @private +*/ DisplayObject.prototype._renderCachedCanvas = function(renderer) { this._initCachedDisplayObjectCanvas( renderer ); @@ -141,6 +167,12 @@ }; //TODO this can be the same as the webGL verison.. will need to do a little tweaking first though.. +/** +* Prepares the Canvas renderer to cache the sprite +* +* @param renderer {CanvasRenderer} the Canvas renderer +* @private +*/ DisplayObject.prototype._initCachedDisplayObjectCanvas = function( renderer ) { if(this._cachedSprite) @@ -171,7 +203,7 @@ this.renderCanvas = this._renderCachedCanvas; this.updateTransform = this.displayObjectUpdateTransform; - this.getBounds = this._getCahcedBounds; + this.getBounds = this._getCachedBounds; // create our cached sprite @@ -182,13 +214,23 @@ this.hitTest = this._cachedSprite.hitTest.bind(this._cachedSprite); }; -DisplayObject.prototype._getCahcedBounds = function() +/** +* Calculates the bounds of the cached sprite +* +* @private +*/ +DisplayObject.prototype._getCachedBounds = function() { this._cachedSprite._currentBounds = null; return this._cachedSprite.getBounds(); }; +/** +* Destroys the cached sprite. +* +* @private +*/ DisplayObject.prototype._destroyCachedDisplayObject = function() { this._cachedSprite._texture.destroy(); diff --git a/src/index.js b/src/index.js index f864027..e3622fb 100644 --- a/src/index.js +++ b/src/index.js @@ -1,4 +1,5 @@ -var core = module.exports = require('./core'); +var core = require('./core'), + deprecation = require('./deprecation'); // plugins: core.extras = require('./extras'); @@ -7,3 +8,5 @@ core.loaders = require('./loaders'); core.spine = require('./spine'); core.text = require('./text'); + +module.exports = core; diff --git a/src/core/index.js b/src/core/index.js index b67c15a..dcbf19d 100644 --- a/src/core/index.js +++ b/src/core/index.js @@ -80,16 +80,6 @@ } return new core.CanvasRenderer(width, height, options); - }, - - Stage: function () - { - window.console.warn("You don't need to use a PIXI Stage any more, you can simply render any container"); - return new core.Container(); - }, - - SpriteBatch: function () { - window.console.warn("SpriteBatch doesn't exist any more, please use the new ParticleContainer instead"); } }; diff --git a/src/core/sprites/Sprite.js b/src/core/sprites/Sprite.js index e3c6b54..96e06db 100644 --- a/src/core/sprites/Sprite.js +++ b/src/core/sprites/Sprite.js @@ -510,11 +510,6 @@ } }; -Sprite.prototype.setTexture = function () -{ - window.console.warn('setTexture is now deprecated, please use the texture property, e.g : sprite.texture = texture; '); -}; - // some helper functions.. /** diff --git a/src/deprecation.js b/src/deprecation.js new file mode 100644 index 0000000..60d052f --- /dev/null +++ b/src/deprecation.js @@ -0,0 +1,37 @@ +var core = require('./core'), + text = require('./text'); + +core.Stage = function () +{ + window.console.warn("You don't need to use a PIXI Stage any more, you can simply render any container."); + return new core.Container(); +}; + +core.SpriteBatch = function () +{ + window.console.warn("SpriteBatch doesn't exist any more, please use the new ParticleContainer instead."); +}; + +core.AssetsLoader = function () { + window.console.warn("The loader system was overhauled in pixi v3, please see the new PIXI.Loader class."); +}; + +core.Sprite.prototype.setTexture = function (texture) +{ + this.texture = texture; + window.console.warn("setTexture is now deprecated, please use the texture property, e.g : sprite.texture = texture;"); +}; + +text.BitmapText.prototype.setText = function (text) +{ + this.text = text; + window.console.warn("setText is now deprecated, please use the text property, e.g : myBitmapText.text = 'my text';"); +}; + +text.Text.prototype.setText = function (text) +{ + this.text = text; + window.console.warn("setText is now deprecated, please use the text property, e.g : myText.text = 'my text';"); +}; + +module.exports = {}; diff --git a/src/extras/cacheAsBitmap.js b/src/extras/cacheAsBitmap.js index 20f2b99..9fe88df 100644 --- a/src/extras/cacheAsBitmap.js +++ b/src/extras/cacheAsBitmap.js @@ -17,6 +17,15 @@ Object.defineProperties(DisplayObject.prototype, { + + /** + * Set this to true if you want this display object to be cached as a bitmap. + * This basically takes a snap shot of the display object as it is at that moment. It can provide a performance benefit for complex static displayObjects. + * To remove simply set this property to 'null' + * + * @member {boolean} + * @memberof DisplayObject# + */ cacheAsBitmap: { get: function () { @@ -60,12 +69,17 @@ this.getBounds = this._originalGetBounds; this.updateTransform = this._originalUpdateTransform; - this.containsPoint = this._originalContainesPoint; + this.containsPoint = this._originalContainsPoint; } } } }); - +/** +* Renders a cached version of the sprite with WebGL +* +* @param renderer {WebGLRenderer} the WebGL renderer +* @private +*/ DisplayObject.prototype._renderCachedWebGL = function(renderer) { this._initCachedDisplayObject( renderer ); @@ -76,6 +90,12 @@ renderer.plugins.sprite.render( this._cachedSprite ); }; +/** +* Prepares the WebGL renderer to cache the sprite +* +* @param renderer {WebGLRenderer} the WebGL renderer +* @private +*/ DisplayObject.prototype._initCachedDisplayObject = function( renderer ) { if(this._cachedSprite) @@ -83,6 +103,7 @@ return; } + // first we flush anything left in the renderer (otherwise it would get rendered to the cached texture) renderer.currentRenderer.flush(); //this.filters= []; @@ -117,7 +138,7 @@ this.renderWebGL = this._renderCachedWebGL; this.updateTransform = this.displayObjectUpdateTransform; - this.getBounds = this._getCahcedBounds; + this.getBounds = this._getCachedBounds; // create our cached sprite @@ -130,7 +151,12 @@ this.containsPoint = this._cachedSprite.containsPoint.bind(this._cachedSprite); }; - +/** +* Renders a cached version of the sprite with canvas +* +* @param renderer {CanvasRenderer} the Canvas renderer +* @private +*/ DisplayObject.prototype._renderCachedCanvas = function(renderer) { this._initCachedDisplayObjectCanvas( renderer ); @@ -141,6 +167,12 @@ }; //TODO this can be the same as the webGL verison.. will need to do a little tweaking first though.. +/** +* Prepares the Canvas renderer to cache the sprite +* +* @param renderer {CanvasRenderer} the Canvas renderer +* @private +*/ DisplayObject.prototype._initCachedDisplayObjectCanvas = function( renderer ) { if(this._cachedSprite) @@ -171,7 +203,7 @@ this.renderCanvas = this._renderCachedCanvas; this.updateTransform = this.displayObjectUpdateTransform; - this.getBounds = this._getCahcedBounds; + this.getBounds = this._getCachedBounds; // create our cached sprite @@ -182,13 +214,23 @@ this.hitTest = this._cachedSprite.hitTest.bind(this._cachedSprite); }; -DisplayObject.prototype._getCahcedBounds = function() +/** +* Calculates the bounds of the cached sprite +* +* @private +*/ +DisplayObject.prototype._getCachedBounds = function() { this._cachedSprite._currentBounds = null; return this._cachedSprite.getBounds(); }; +/** +* Destroys the cached sprite. +* +* @private +*/ DisplayObject.prototype._destroyCachedDisplayObject = function() { this._cachedSprite._texture.destroy(); diff --git a/src/index.js b/src/index.js index f864027..e3622fb 100644 --- a/src/index.js +++ b/src/index.js @@ -1,4 +1,5 @@ -var core = module.exports = require('./core'); +var core = require('./core'), + deprecation = require('./deprecation'); // plugins: core.extras = require('./extras'); @@ -7,3 +8,5 @@ core.loaders = require('./loaders'); core.spine = require('./spine'); core.text = require('./text'); + +module.exports = core; diff --git a/src/loaders/bitmapFontParser.js b/src/loaders/bitmapFontParser.js index 1c8b400..f0551a1 100644 --- a/src/loaders/bitmapFontParser.js +++ b/src/loaders/bitmapFontParser.js @@ -1,5 +1,6 @@ var Resource = require('resource-loader').Resource, - core = require('../core'); + core = require('../core'), + text = require('../text'); module.exports = function () { @@ -84,6 +85,10 @@ resource.bitmapFont = data; + // I'm leaving this as a temporary fix so we can test the bitmap fonts in v3 + // but it's very likely to change + text.BitmapText.fonts[data.font] = data; + next(); }); }; diff --git a/src/core/index.js b/src/core/index.js index b67c15a..dcbf19d 100644 --- a/src/core/index.js +++ b/src/core/index.js @@ -80,16 +80,6 @@ } return new core.CanvasRenderer(width, height, options); - }, - - Stage: function () - { - window.console.warn("You don't need to use a PIXI Stage any more, you can simply render any container"); - return new core.Container(); - }, - - SpriteBatch: function () { - window.console.warn("SpriteBatch doesn't exist any more, please use the new ParticleContainer instead"); } }; diff --git a/src/core/sprites/Sprite.js b/src/core/sprites/Sprite.js index e3c6b54..96e06db 100644 --- a/src/core/sprites/Sprite.js +++ b/src/core/sprites/Sprite.js @@ -510,11 +510,6 @@ } }; -Sprite.prototype.setTexture = function () -{ - window.console.warn('setTexture is now deprecated, please use the texture property, e.g : sprite.texture = texture; '); -}; - // some helper functions.. /** diff --git a/src/deprecation.js b/src/deprecation.js new file mode 100644 index 0000000..60d052f --- /dev/null +++ b/src/deprecation.js @@ -0,0 +1,37 @@ +var core = require('./core'), + text = require('./text'); + +core.Stage = function () +{ + window.console.warn("You don't need to use a PIXI Stage any more, you can simply render any container."); + return new core.Container(); +}; + +core.SpriteBatch = function () +{ + window.console.warn("SpriteBatch doesn't exist any more, please use the new ParticleContainer instead."); +}; + +core.AssetsLoader = function () { + window.console.warn("The loader system was overhauled in pixi v3, please see the new PIXI.Loader class."); +}; + +core.Sprite.prototype.setTexture = function (texture) +{ + this.texture = texture; + window.console.warn("setTexture is now deprecated, please use the texture property, e.g : sprite.texture = texture;"); +}; + +text.BitmapText.prototype.setText = function (text) +{ + this.text = text; + window.console.warn("setText is now deprecated, please use the text property, e.g : myBitmapText.text = 'my text';"); +}; + +text.Text.prototype.setText = function (text) +{ + this.text = text; + window.console.warn("setText is now deprecated, please use the text property, e.g : myText.text = 'my text';"); +}; + +module.exports = {}; diff --git a/src/extras/cacheAsBitmap.js b/src/extras/cacheAsBitmap.js index 20f2b99..9fe88df 100644 --- a/src/extras/cacheAsBitmap.js +++ b/src/extras/cacheAsBitmap.js @@ -17,6 +17,15 @@ Object.defineProperties(DisplayObject.prototype, { + + /** + * Set this to true if you want this display object to be cached as a bitmap. + * This basically takes a snap shot of the display object as it is at that moment. It can provide a performance benefit for complex static displayObjects. + * To remove simply set this property to 'null' + * + * @member {boolean} + * @memberof DisplayObject# + */ cacheAsBitmap: { get: function () { @@ -60,12 +69,17 @@ this.getBounds = this._originalGetBounds; this.updateTransform = this._originalUpdateTransform; - this.containsPoint = this._originalContainesPoint; + this.containsPoint = this._originalContainsPoint; } } } }); - +/** +* Renders a cached version of the sprite with WebGL +* +* @param renderer {WebGLRenderer} the WebGL renderer +* @private +*/ DisplayObject.prototype._renderCachedWebGL = function(renderer) { this._initCachedDisplayObject( renderer ); @@ -76,6 +90,12 @@ renderer.plugins.sprite.render( this._cachedSprite ); }; +/** +* Prepares the WebGL renderer to cache the sprite +* +* @param renderer {WebGLRenderer} the WebGL renderer +* @private +*/ DisplayObject.prototype._initCachedDisplayObject = function( renderer ) { if(this._cachedSprite) @@ -83,6 +103,7 @@ return; } + // first we flush anything left in the renderer (otherwise it would get rendered to the cached texture) renderer.currentRenderer.flush(); //this.filters= []; @@ -117,7 +138,7 @@ this.renderWebGL = this._renderCachedWebGL; this.updateTransform = this.displayObjectUpdateTransform; - this.getBounds = this._getCahcedBounds; + this.getBounds = this._getCachedBounds; // create our cached sprite @@ -130,7 +151,12 @@ this.containsPoint = this._cachedSprite.containsPoint.bind(this._cachedSprite); }; - +/** +* Renders a cached version of the sprite with canvas +* +* @param renderer {CanvasRenderer} the Canvas renderer +* @private +*/ DisplayObject.prototype._renderCachedCanvas = function(renderer) { this._initCachedDisplayObjectCanvas( renderer ); @@ -141,6 +167,12 @@ }; //TODO this can be the same as the webGL verison.. will need to do a little tweaking first though.. +/** +* Prepares the Canvas renderer to cache the sprite +* +* @param renderer {CanvasRenderer} the Canvas renderer +* @private +*/ DisplayObject.prototype._initCachedDisplayObjectCanvas = function( renderer ) { if(this._cachedSprite) @@ -171,7 +203,7 @@ this.renderCanvas = this._renderCachedCanvas; this.updateTransform = this.displayObjectUpdateTransform; - this.getBounds = this._getCahcedBounds; + this.getBounds = this._getCachedBounds; // create our cached sprite @@ -182,13 +214,23 @@ this.hitTest = this._cachedSprite.hitTest.bind(this._cachedSprite); }; -DisplayObject.prototype._getCahcedBounds = function() +/** +* Calculates the bounds of the cached sprite +* +* @private +*/ +DisplayObject.prototype._getCachedBounds = function() { this._cachedSprite._currentBounds = null; return this._cachedSprite.getBounds(); }; +/** +* Destroys the cached sprite. +* +* @private +*/ DisplayObject.prototype._destroyCachedDisplayObject = function() { this._cachedSprite._texture.destroy(); diff --git a/src/index.js b/src/index.js index f864027..e3622fb 100644 --- a/src/index.js +++ b/src/index.js @@ -1,4 +1,5 @@ -var core = module.exports = require('./core'); +var core = require('./core'), + deprecation = require('./deprecation'); // plugins: core.extras = require('./extras'); @@ -7,3 +8,5 @@ core.loaders = require('./loaders'); core.spine = require('./spine'); core.text = require('./text'); + +module.exports = core; diff --git a/src/loaders/bitmapFontParser.js b/src/loaders/bitmapFontParser.js index 1c8b400..f0551a1 100644 --- a/src/loaders/bitmapFontParser.js +++ b/src/loaders/bitmapFontParser.js @@ -1,5 +1,6 @@ var Resource = require('resource-loader').Resource, - core = require('../core'); + core = require('../core'), + text = require('../text'); module.exports = function () { @@ -84,6 +85,10 @@ resource.bitmapFont = data; + // I'm leaving this as a temporary fix so we can test the bitmap fonts in v3 + // but it's very likely to change + text.BitmapText.fonts[data.font] = data; + next(); }); }; diff --git a/src/text/BitmapText.js b/src/text/BitmapText.js index 2ffd2b4..898b468 100644 --- a/src/text/BitmapText.js +++ b/src/text/BitmapText.js @@ -10,7 +10,7 @@ * // in this case the font is in a file called 'desyrel.fnt' * var bitmapText = new PIXI.BitmapText("text using a fancy font!", {font: "35px Desyrel", align: "right"}); * ``` - * + * * * http://www.angelcode.com/products/bmfont/ for windows or * http://www.bmglyph.com/ for mac. @@ -203,7 +203,7 @@ */ BitmapText.prototype.updateText = function () { - var data = BitmapText.fonts[this.fontName]; + var data = BitmapText.fonts[this._style.fontName]; var pos = new core.math.Point(); var prevCharCode = null; var chars = []; @@ -275,11 +275,11 @@ { var alignOffset = 0; - if (this.style.align === 'right') + if (this._style.align === 'right') { alignOffset = maxLineWidth - lineWidths[i]; } - else if (this.style.align === 'center') + else if (this._style.align === 'center') { alignOffset = (maxLineWidth - lineWidths[i]) / 2; } @@ -341,9 +341,4 @@ this.containerUpdateTransform(); }; -BitmapText.prototype.setText = function () -{ - window.console.warn(" setText is now deprecated, please use the text property, e.g : myBitmapText.text = 'my text'; "); -}; - BitmapText.fonts = {}; diff --git a/src/core/index.js b/src/core/index.js index b67c15a..dcbf19d 100644 --- a/src/core/index.js +++ b/src/core/index.js @@ -80,16 +80,6 @@ } return new core.CanvasRenderer(width, height, options); - }, - - Stage: function () - { - window.console.warn("You don't need to use a PIXI Stage any more, you can simply render any container"); - return new core.Container(); - }, - - SpriteBatch: function () { - window.console.warn("SpriteBatch doesn't exist any more, please use the new ParticleContainer instead"); } }; diff --git a/src/core/sprites/Sprite.js b/src/core/sprites/Sprite.js index e3c6b54..96e06db 100644 --- a/src/core/sprites/Sprite.js +++ b/src/core/sprites/Sprite.js @@ -510,11 +510,6 @@ } }; -Sprite.prototype.setTexture = function () -{ - window.console.warn('setTexture is now deprecated, please use the texture property, e.g : sprite.texture = texture; '); -}; - // some helper functions.. /** diff --git a/src/deprecation.js b/src/deprecation.js new file mode 100644 index 0000000..60d052f --- /dev/null +++ b/src/deprecation.js @@ -0,0 +1,37 @@ +var core = require('./core'), + text = require('./text'); + +core.Stage = function () +{ + window.console.warn("You don't need to use a PIXI Stage any more, you can simply render any container."); + return new core.Container(); +}; + +core.SpriteBatch = function () +{ + window.console.warn("SpriteBatch doesn't exist any more, please use the new ParticleContainer instead."); +}; + +core.AssetsLoader = function () { + window.console.warn("The loader system was overhauled in pixi v3, please see the new PIXI.Loader class."); +}; + +core.Sprite.prototype.setTexture = function (texture) +{ + this.texture = texture; + window.console.warn("setTexture is now deprecated, please use the texture property, e.g : sprite.texture = texture;"); +}; + +text.BitmapText.prototype.setText = function (text) +{ + this.text = text; + window.console.warn("setText is now deprecated, please use the text property, e.g : myBitmapText.text = 'my text';"); +}; + +text.Text.prototype.setText = function (text) +{ + this.text = text; + window.console.warn("setText is now deprecated, please use the text property, e.g : myText.text = 'my text';"); +}; + +module.exports = {}; diff --git a/src/extras/cacheAsBitmap.js b/src/extras/cacheAsBitmap.js index 20f2b99..9fe88df 100644 --- a/src/extras/cacheAsBitmap.js +++ b/src/extras/cacheAsBitmap.js @@ -17,6 +17,15 @@ Object.defineProperties(DisplayObject.prototype, { + + /** + * Set this to true if you want this display object to be cached as a bitmap. + * This basically takes a snap shot of the display object as it is at that moment. It can provide a performance benefit for complex static displayObjects. + * To remove simply set this property to 'null' + * + * @member {boolean} + * @memberof DisplayObject# + */ cacheAsBitmap: { get: function () { @@ -60,12 +69,17 @@ this.getBounds = this._originalGetBounds; this.updateTransform = this._originalUpdateTransform; - this.containsPoint = this._originalContainesPoint; + this.containsPoint = this._originalContainsPoint; } } } }); - +/** +* Renders a cached version of the sprite with WebGL +* +* @param renderer {WebGLRenderer} the WebGL renderer +* @private +*/ DisplayObject.prototype._renderCachedWebGL = function(renderer) { this._initCachedDisplayObject( renderer ); @@ -76,6 +90,12 @@ renderer.plugins.sprite.render( this._cachedSprite ); }; +/** +* Prepares the WebGL renderer to cache the sprite +* +* @param renderer {WebGLRenderer} the WebGL renderer +* @private +*/ DisplayObject.prototype._initCachedDisplayObject = function( renderer ) { if(this._cachedSprite) @@ -83,6 +103,7 @@ return; } + // first we flush anything left in the renderer (otherwise it would get rendered to the cached texture) renderer.currentRenderer.flush(); //this.filters= []; @@ -117,7 +138,7 @@ this.renderWebGL = this._renderCachedWebGL; this.updateTransform = this.displayObjectUpdateTransform; - this.getBounds = this._getCahcedBounds; + this.getBounds = this._getCachedBounds; // create our cached sprite @@ -130,7 +151,12 @@ this.containsPoint = this._cachedSprite.containsPoint.bind(this._cachedSprite); }; - +/** +* Renders a cached version of the sprite with canvas +* +* @param renderer {CanvasRenderer} the Canvas renderer +* @private +*/ DisplayObject.prototype._renderCachedCanvas = function(renderer) { this._initCachedDisplayObjectCanvas( renderer ); @@ -141,6 +167,12 @@ }; //TODO this can be the same as the webGL verison.. will need to do a little tweaking first though.. +/** +* Prepares the Canvas renderer to cache the sprite +* +* @param renderer {CanvasRenderer} the Canvas renderer +* @private +*/ DisplayObject.prototype._initCachedDisplayObjectCanvas = function( renderer ) { if(this._cachedSprite) @@ -171,7 +203,7 @@ this.renderCanvas = this._renderCachedCanvas; this.updateTransform = this.displayObjectUpdateTransform; - this.getBounds = this._getCahcedBounds; + this.getBounds = this._getCachedBounds; // create our cached sprite @@ -182,13 +214,23 @@ this.hitTest = this._cachedSprite.hitTest.bind(this._cachedSprite); }; -DisplayObject.prototype._getCahcedBounds = function() +/** +* Calculates the bounds of the cached sprite +* +* @private +*/ +DisplayObject.prototype._getCachedBounds = function() { this._cachedSprite._currentBounds = null; return this._cachedSprite.getBounds(); }; +/** +* Destroys the cached sprite. +* +* @private +*/ DisplayObject.prototype._destroyCachedDisplayObject = function() { this._cachedSprite._texture.destroy(); diff --git a/src/index.js b/src/index.js index f864027..e3622fb 100644 --- a/src/index.js +++ b/src/index.js @@ -1,4 +1,5 @@ -var core = module.exports = require('./core'); +var core = require('./core'), + deprecation = require('./deprecation'); // plugins: core.extras = require('./extras'); @@ -7,3 +8,5 @@ core.loaders = require('./loaders'); core.spine = require('./spine'); core.text = require('./text'); + +module.exports = core; diff --git a/src/loaders/bitmapFontParser.js b/src/loaders/bitmapFontParser.js index 1c8b400..f0551a1 100644 --- a/src/loaders/bitmapFontParser.js +++ b/src/loaders/bitmapFontParser.js @@ -1,5 +1,6 @@ var Resource = require('resource-loader').Resource, - core = require('../core'); + core = require('../core'), + text = require('../text'); module.exports = function () { @@ -84,6 +85,10 @@ resource.bitmapFont = data; + // I'm leaving this as a temporary fix so we can test the bitmap fonts in v3 + // but it's very likely to change + text.BitmapText.fonts[data.font] = data; + next(); }); }; diff --git a/src/text/BitmapText.js b/src/text/BitmapText.js index 2ffd2b4..898b468 100644 --- a/src/text/BitmapText.js +++ b/src/text/BitmapText.js @@ -10,7 +10,7 @@ * // in this case the font is in a file called 'desyrel.fnt' * var bitmapText = new PIXI.BitmapText("text using a fancy font!", {font: "35px Desyrel", align: "right"}); * ``` - * + * * * http://www.angelcode.com/products/bmfont/ for windows or * http://www.bmglyph.com/ for mac. @@ -203,7 +203,7 @@ */ BitmapText.prototype.updateText = function () { - var data = BitmapText.fonts[this.fontName]; + var data = BitmapText.fonts[this._style.fontName]; var pos = new core.math.Point(); var prevCharCode = null; var chars = []; @@ -275,11 +275,11 @@ { var alignOffset = 0; - if (this.style.align === 'right') + if (this._style.align === 'right') { alignOffset = maxLineWidth - lineWidths[i]; } - else if (this.style.align === 'center') + else if (this._style.align === 'center') { alignOffset = (maxLineWidth - lineWidths[i]) / 2; } @@ -341,9 +341,4 @@ this.containerUpdateTransform(); }; -BitmapText.prototype.setText = function () -{ - window.console.warn(" setText is now deprecated, please use the text property, e.g : myBitmapText.text = 'my text'; "); -}; - BitmapText.fonts = {}; diff --git a/src/text/Text.js b/src/text/Text.js index 000815b..4e3bdf2 100644 --- a/src/text/Text.js +++ b/src/text/Text.js @@ -553,8 +553,3 @@ this._texture.destroy(destroyBaseTexture === undefined ? true : destroyBaseTexture); }; - -Text.prototype.setText = function () -{ - window.console.warn(" setText is now deprecated, please use the text property, e.g : myText.text = 'my text'; "); -};