diff --git a/src/deprecation.js b/src/deprecation.js index 652759c..4bcd914 100644 --- a/src/deprecation.js +++ b/src/deprecation.js @@ -1,4 +1,3 @@ -// @if DEBUG /*global console */ var core = require('./core'), mesh = require('./mesh'), @@ -6,6 +5,7 @@ extras = require('./extras'), filters = require('./filters'); +// @if DEBUG // provide method to give a stack track for warnings // useful for tracking-down where deprecated methods/properties/classes // are being used within the code @@ -31,6 +31,7 @@ } } } +// @endif /** * @class @@ -73,7 +74,9 @@ Stage: { get: function() { + // @if DEBUG warn('You do not need to use a PIXI Stage any more, you can simply render any container.'); + // @endif return core.Container; } }, @@ -89,7 +92,9 @@ DisplayObjectContainer: { get: function() { + // @if DEBUG warn('DisplayObjectContainer has been shortened to Container, please use Container from now on.'); + // @endif return core.Container; } }, @@ -105,7 +110,9 @@ Strip: { get: function() { + // @if DEBUG warn('The Strip class has been renamed to Mesh and moved to mesh.Mesh, please use mesh.Mesh from now on.'); + // @endif return mesh.Mesh; } }, @@ -121,7 +128,9 @@ Rope: { get: function() { + // @if DEBUG warn('The Rope class has been moved to mesh.Rope, please use mesh.Rope from now on.'); + // @endif return mesh.Rope; } }, @@ -136,7 +145,9 @@ */ ParticleContainer: { get: function() { + // @if DEBUG warn('The ParticleContainer class has been moved to particles.ParticleContainer, please use particles.ParticleContainer from now on.'); + // @endif return particles.ParticleContainer; } }, @@ -152,7 +163,9 @@ MovieClip: { get: function() { + // @if DEBUG warn('The MovieClip class has been moved to extras.MovieClip, please use extras.MovieClip from now on.'); + // @endif return extras.MovieClip; } }, @@ -168,7 +181,9 @@ TilingSprite: { get: function() { + // @if DEBUG warn('The TilingSprite class has been moved to extras.TilingSprite, please use extras.TilingSprite from now on.'); + // @endif return extras.TilingSprite; } }, @@ -184,7 +199,9 @@ BitmapText: { get: function() { + // @if DEBUG warn('The BitmapText class has been moved to extras.BitmapText, please use extras.BitmapText from now on.'); + // @endif return extras.BitmapText; } }, @@ -200,7 +217,9 @@ blendModes: { get: function() { + // @if DEBUG warn('The blendModes has been moved to BLEND_MODES, please use BLEND_MODES from now on.'); + // @endif return core.BLEND_MODES; } }, @@ -216,7 +235,9 @@ scaleModes: { get: function() { + // @if DEBUG warn('The scaleModes has been moved to SCALE_MODES, please use SCALE_MODES from now on.'); + // @endif return core.SCALE_MODES; } }, @@ -232,7 +253,9 @@ BaseTextureCache: { get: function () { + // @if DEBUG warn('The BaseTextureCache class has been moved to utils.BaseTextureCache, please use utils.BaseTextureCache from now on.'); + // @endif return core.utils.BaseTextureCache; } }, @@ -248,7 +271,9 @@ TextureCache: { get: function () { + // @if DEBUG warn('The TextureCache class has been moved to utils.TextureCache, please use utils.TextureCache from now on.'); + // @endif return core.utils.TextureCache; } }, @@ -264,7 +289,9 @@ math: { get: function () { + // @if DEBUG warn('The math namespace is deprecated, please access members already accessible on PIXI.'); + // @endif return core; } }, @@ -279,7 +306,9 @@ AbstractFilter: { get: function() { + // @if DEBUG warn('AstractFilter has been renamed to Filter, please use PIXI.Filter'); + // @endif return core.Filter; } }, @@ -294,7 +323,9 @@ TransformManual: { get: function() { + // @if DEBUG warn('TransformManual has been renamed to TransformBase, please update your pixi-spine'); + // @endif return core.TransformBase; } } @@ -302,44 +333,58 @@ core.DisplayObject.prototype.generateTexture = function(renderer, scaleMode, resolution) { + // @if DEBUG warn('generateTexture has moved to the renderer, please use renderer.generateTexture(displayObject)'); + // @endif return renderer.generateTexture(this, scaleMode, resolution); }; core.Graphics.prototype.generateTexture = function(scaleMode, resolution) { + // @if DEBUG warn('graphics generate texture has moved to the renderer. Or to render a graphics to a texture using canvas please use generateCanvasTexture'); + // @endif return this.generateCanvasTexture(scaleMode, resolution); }; core.RenderTexture.prototype.render = function(displayObject, matrix, clear, updateTransform) { this.legacyRenderer.render(displayObject, this, clear, matrix, !updateTransform); + // @if DEBUG warn('RenderTexture.render is now deprecated, please use renderer.render(displayObject, renderTexture)'); + // @endif }; core.RenderTexture.prototype.getImage = function(target) { + // @if DEBUG warn('RenderTexture.getImage is now deprecated, please use renderer.extract.image(target)'); + // @endif return this.legacyRenderer.extract.image(target); }; core.RenderTexture.prototype.getBase64 = function(target) { + // @if DEBUG warn('RenderTexture.getBase64 is now deprecated, please use renderer.extract.base64(target)'); + // @endif return this.legacyRenderer.extract.base64(target); }; core.RenderTexture.prototype.getCanvas = function(target) { + // @if DEBUG warn('RenderTexture.getCanvas is now deprecated, please use renderer.extract.canvas(target)'); + // @endif return this.legacyRenderer.extract.canvas(target); }; core.RenderTexture.prototype.getPixels = function(target) { + // @if DEBUG warn('RenderTexture.getPixels is now deprecated, please use renderer.extract.pixels(target)'); + // @endif return this.legacyRenderer.pixels(target); }; @@ -355,7 +400,9 @@ core.Sprite.prototype.setTexture = function(texture) { this.texture = texture; + // @if DEBUG warn('setTexture is now deprecated, please use the texture property, e.g : sprite.texture = texture;'); + // @endif }; @@ -369,7 +416,9 @@ extras.BitmapText.prototype.setText = function(text) { this.text = text; + // @if DEBUG warn('setText is now deprecated, please use the text property, e.g : myBitmapText.text = \'my text\';'); + // @endif }; /** @@ -381,7 +430,9 @@ core.Text.prototype.setText = function(text) { this.text = text; + // @if DEBUG warn('setText is now deprecated, please use the text property, e.g : myText.text = \'my text\';'); + // @endif }; /** @@ -393,7 +444,9 @@ core.Text.prototype.setStyle = function(style) { this.style = style; + // @if DEBUG warn('setStyle is now deprecated, please use the style property, e.g : myText.style = style;'); + // @endif }; Object.defineProperties(core.TextStyle.prototype, { @@ -406,13 +459,17 @@ font: { get: function () { + // @if DEBUG warn('text style property \'font\' is now deprecated, please use the \'fontFamily\',\'fontSize\',fontStyle\',\'fontVariant\' and \'fontWeight\' properties from now on'); + // @endif var fontSizeString = (typeof this._fontSize === 'number') ? this._fontSize + 'px' : this._fontSize; return this._fontStyle + ' ' + this._fontVariant + ' ' + this._fontWeight + ' ' + fontSizeString + ' ' + this._fontFamily; }, set: function (font) { + // @if DEBUG warn('text style property \'font\' is now deprecated, please use the \'fontFamily\',\'fontSize\',fontStyle\',\'fontVariant\' and \'fontWeight\' properties from now on'); + // @endif // can work out fontStyle from search of whole string if ( font.indexOf('italic') > 1 ) @@ -495,7 +552,9 @@ core.Texture.prototype.setFrame = function(frame) { this.frame = frame; + // @if DEBUG warn('setFrame is now deprecated, please use the frame property, e.g : myTexture.frame = frame;'); + // @endif }; Object.defineProperties(filters, { @@ -510,7 +569,9 @@ AbstractFilter: { get: function() { + // @if DEBUG warn('AstractFilter has been renamed to Filter, please use PIXI.Filter'); + // @endif return core.AbstractFilter; } }, @@ -525,7 +586,9 @@ SpriteMaskFilter: { get: function() { + // @if DEBUG warn('filters.SpriteMaskFilter is an undocumented alias, please use SpriteMaskFilter from now on.'); + // @endif return core.SpriteMaskFilter; } } @@ -539,7 +602,9 @@ */ core.utils.uuid = function () { + // @if DEBUG warn('utils.uuid() is deprecated, please use utils.uid() from now on.'); + // @endif return core.utils.uid(); }; @@ -550,7 +615,8 @@ * @deprecated */ core.utils.canUseNewCanvasBlendModes = function() { + // @if DEBUG warn('utils.canUseNewCanvasBlendModes() is deprecated, please use CanvasTinter.canUseMultiply from now on'); + // @endif return core.CanvasTinter.canUseMultiply; -}; -// @endif \ No newline at end of file +}; \ No newline at end of file diff --git a/src/deprecation.js b/src/deprecation.js index 652759c..4bcd914 100644 --- a/src/deprecation.js +++ b/src/deprecation.js @@ -1,4 +1,3 @@ -// @if DEBUG /*global console */ var core = require('./core'), mesh = require('./mesh'), @@ -6,6 +5,7 @@ extras = require('./extras'), filters = require('./filters'); +// @if DEBUG // provide method to give a stack track for warnings // useful for tracking-down where deprecated methods/properties/classes // are being used within the code @@ -31,6 +31,7 @@ } } } +// @endif /** * @class @@ -73,7 +74,9 @@ Stage: { get: function() { + // @if DEBUG warn('You do not need to use a PIXI Stage any more, you can simply render any container.'); + // @endif return core.Container; } }, @@ -89,7 +92,9 @@ DisplayObjectContainer: { get: function() { + // @if DEBUG warn('DisplayObjectContainer has been shortened to Container, please use Container from now on.'); + // @endif return core.Container; } }, @@ -105,7 +110,9 @@ Strip: { get: function() { + // @if DEBUG warn('The Strip class has been renamed to Mesh and moved to mesh.Mesh, please use mesh.Mesh from now on.'); + // @endif return mesh.Mesh; } }, @@ -121,7 +128,9 @@ Rope: { get: function() { + // @if DEBUG warn('The Rope class has been moved to mesh.Rope, please use mesh.Rope from now on.'); + // @endif return mesh.Rope; } }, @@ -136,7 +145,9 @@ */ ParticleContainer: { get: function() { + // @if DEBUG warn('The ParticleContainer class has been moved to particles.ParticleContainer, please use particles.ParticleContainer from now on.'); + // @endif return particles.ParticleContainer; } }, @@ -152,7 +163,9 @@ MovieClip: { get: function() { + // @if DEBUG warn('The MovieClip class has been moved to extras.MovieClip, please use extras.MovieClip from now on.'); + // @endif return extras.MovieClip; } }, @@ -168,7 +181,9 @@ TilingSprite: { get: function() { + // @if DEBUG warn('The TilingSprite class has been moved to extras.TilingSprite, please use extras.TilingSprite from now on.'); + // @endif return extras.TilingSprite; } }, @@ -184,7 +199,9 @@ BitmapText: { get: function() { + // @if DEBUG warn('The BitmapText class has been moved to extras.BitmapText, please use extras.BitmapText from now on.'); + // @endif return extras.BitmapText; } }, @@ -200,7 +217,9 @@ blendModes: { get: function() { + // @if DEBUG warn('The blendModes has been moved to BLEND_MODES, please use BLEND_MODES from now on.'); + // @endif return core.BLEND_MODES; } }, @@ -216,7 +235,9 @@ scaleModes: { get: function() { + // @if DEBUG warn('The scaleModes has been moved to SCALE_MODES, please use SCALE_MODES from now on.'); + // @endif return core.SCALE_MODES; } }, @@ -232,7 +253,9 @@ BaseTextureCache: { get: function () { + // @if DEBUG warn('The BaseTextureCache class has been moved to utils.BaseTextureCache, please use utils.BaseTextureCache from now on.'); + // @endif return core.utils.BaseTextureCache; } }, @@ -248,7 +271,9 @@ TextureCache: { get: function () { + // @if DEBUG warn('The TextureCache class has been moved to utils.TextureCache, please use utils.TextureCache from now on.'); + // @endif return core.utils.TextureCache; } }, @@ -264,7 +289,9 @@ math: { get: function () { + // @if DEBUG warn('The math namespace is deprecated, please access members already accessible on PIXI.'); + // @endif return core; } }, @@ -279,7 +306,9 @@ AbstractFilter: { get: function() { + // @if DEBUG warn('AstractFilter has been renamed to Filter, please use PIXI.Filter'); + // @endif return core.Filter; } }, @@ -294,7 +323,9 @@ TransformManual: { get: function() { + // @if DEBUG warn('TransformManual has been renamed to TransformBase, please update your pixi-spine'); + // @endif return core.TransformBase; } } @@ -302,44 +333,58 @@ core.DisplayObject.prototype.generateTexture = function(renderer, scaleMode, resolution) { + // @if DEBUG warn('generateTexture has moved to the renderer, please use renderer.generateTexture(displayObject)'); + // @endif return renderer.generateTexture(this, scaleMode, resolution); }; core.Graphics.prototype.generateTexture = function(scaleMode, resolution) { + // @if DEBUG warn('graphics generate texture has moved to the renderer. Or to render a graphics to a texture using canvas please use generateCanvasTexture'); + // @endif return this.generateCanvasTexture(scaleMode, resolution); }; core.RenderTexture.prototype.render = function(displayObject, matrix, clear, updateTransform) { this.legacyRenderer.render(displayObject, this, clear, matrix, !updateTransform); + // @if DEBUG warn('RenderTexture.render is now deprecated, please use renderer.render(displayObject, renderTexture)'); + // @endif }; core.RenderTexture.prototype.getImage = function(target) { + // @if DEBUG warn('RenderTexture.getImage is now deprecated, please use renderer.extract.image(target)'); + // @endif return this.legacyRenderer.extract.image(target); }; core.RenderTexture.prototype.getBase64 = function(target) { + // @if DEBUG warn('RenderTexture.getBase64 is now deprecated, please use renderer.extract.base64(target)'); + // @endif return this.legacyRenderer.extract.base64(target); }; core.RenderTexture.prototype.getCanvas = function(target) { + // @if DEBUG warn('RenderTexture.getCanvas is now deprecated, please use renderer.extract.canvas(target)'); + // @endif return this.legacyRenderer.extract.canvas(target); }; core.RenderTexture.prototype.getPixels = function(target) { + // @if DEBUG warn('RenderTexture.getPixels is now deprecated, please use renderer.extract.pixels(target)'); + // @endif return this.legacyRenderer.pixels(target); }; @@ -355,7 +400,9 @@ core.Sprite.prototype.setTexture = function(texture) { this.texture = texture; + // @if DEBUG warn('setTexture is now deprecated, please use the texture property, e.g : sprite.texture = texture;'); + // @endif }; @@ -369,7 +416,9 @@ extras.BitmapText.prototype.setText = function(text) { this.text = text; + // @if DEBUG warn('setText is now deprecated, please use the text property, e.g : myBitmapText.text = \'my text\';'); + // @endif }; /** @@ -381,7 +430,9 @@ core.Text.prototype.setText = function(text) { this.text = text; + // @if DEBUG warn('setText is now deprecated, please use the text property, e.g : myText.text = \'my text\';'); + // @endif }; /** @@ -393,7 +444,9 @@ core.Text.prototype.setStyle = function(style) { this.style = style; + // @if DEBUG warn('setStyle is now deprecated, please use the style property, e.g : myText.style = style;'); + // @endif }; Object.defineProperties(core.TextStyle.prototype, { @@ -406,13 +459,17 @@ font: { get: function () { + // @if DEBUG warn('text style property \'font\' is now deprecated, please use the \'fontFamily\',\'fontSize\',fontStyle\',\'fontVariant\' and \'fontWeight\' properties from now on'); + // @endif var fontSizeString = (typeof this._fontSize === 'number') ? this._fontSize + 'px' : this._fontSize; return this._fontStyle + ' ' + this._fontVariant + ' ' + this._fontWeight + ' ' + fontSizeString + ' ' + this._fontFamily; }, set: function (font) { + // @if DEBUG warn('text style property \'font\' is now deprecated, please use the \'fontFamily\',\'fontSize\',fontStyle\',\'fontVariant\' and \'fontWeight\' properties from now on'); + // @endif // can work out fontStyle from search of whole string if ( font.indexOf('italic') > 1 ) @@ -495,7 +552,9 @@ core.Texture.prototype.setFrame = function(frame) { this.frame = frame; + // @if DEBUG warn('setFrame is now deprecated, please use the frame property, e.g : myTexture.frame = frame;'); + // @endif }; Object.defineProperties(filters, { @@ -510,7 +569,9 @@ AbstractFilter: { get: function() { + // @if DEBUG warn('AstractFilter has been renamed to Filter, please use PIXI.Filter'); + // @endif return core.AbstractFilter; } }, @@ -525,7 +586,9 @@ SpriteMaskFilter: { get: function() { + // @if DEBUG warn('filters.SpriteMaskFilter is an undocumented alias, please use SpriteMaskFilter from now on.'); + // @endif return core.SpriteMaskFilter; } } @@ -539,7 +602,9 @@ */ core.utils.uuid = function () { + // @if DEBUG warn('utils.uuid() is deprecated, please use utils.uid() from now on.'); + // @endif return core.utils.uid(); }; @@ -550,7 +615,8 @@ * @deprecated */ core.utils.canUseNewCanvasBlendModes = function() { + // @if DEBUG warn('utils.canUseNewCanvasBlendModes() is deprecated, please use CanvasTinter.canUseMultiply from now on'); + // @endif return core.CanvasTinter.canUseMultiply; -}; -// @endif \ No newline at end of file +}; \ No newline at end of file diff --git a/src/index.js b/src/index.js index a10440c..645f8f3 100644 --- a/src/index.js +++ b/src/index.js @@ -24,10 +24,8 @@ */ core.loader = new core.loaders.Loader(); -// @if DEBUG // mixin the deprecation features. Object.assign(core, require('./deprecation')); -// @endif // Always export pixi globally. global.PIXI = core;