77*
88* Phaser - http://phaser.io
99*
10- * v2.1.4 "Bethal" - Built: Sat Nov 08 2014 19:03:01
10+ * v2.2.0 "Bethal" - Built: Sat Nov 08 2014 19:24:51
1111*
1212* By Richard Davey http://www.photonstorm.com @photonstorm
1313*
@@ -365,8 +365,8 @@ PIXI.Matrix.prototype.apply = function(pos, newPos)
365365{
366366 newPos = newPos || new PIXI.Point();
367367
368- newPos.x = this.a * pos.x + this.b * pos.y + this.tx;
369- newPos.y = this.c * pos.x + this.d * pos.y + this.ty;
368+ newPos.x = this.a * pos.x + this.c * pos.y + this.tx;
369+ newPos.y = this.b * pos.x + this.d * pos.y + this.ty;
370370
371371 return newPos;
372372};
@@ -1802,8 +1802,8 @@ PIXI.DisplayObjectContainer.prototype._renderCanvas = function(renderSession)
18021802 * @extends DisplayObjectContainer
18031803 * @constructor
18041804 * @param texture {Texture} The texture for this sprite
1805- *
1806- * A sprite can be created directly from an image like this :
1805+ *
1806+ * A sprite can be created directly from an image like this :
18071807 * var sprite = new PIXI.Sprite.fromImage('assets/image.png');
18081808 * yourStage.addChild(sprite);
18091809 * then obviously don't forget to add it to the stage you have already created
@@ -1857,7 +1857,7 @@ PIXI.Sprite = function(texture)
18571857 * @default 0xFFFFFF
18581858 */
18591859 this.tint = 0xFFFFFF;
1860-
1860+
18611861 /**
18621862 * The blend mode to be applied to the sprite. Set to PIXI.blendModes.NORMAL to remove any blend mode.
18631863 *
@@ -1882,8 +1882,7 @@ PIXI.Sprite = function(texture)
18821882 }
18831883 else
18841884 {
1885- this.onTextureUpdateBind = this.onTextureUpdate.bind(this);
1886- this.texture.on( 'update', this.onTextureUpdateBind );
1885+ this.texture.on( 'update', this.onTextureUpdate.bind(this) );
18871886 }
18881887
18891888 this.renderable = true;
@@ -2037,14 +2036,14 @@ PIXI.Sprite.prototype.getBounds = function(matrix)
20372036* Renders the object using the WebGL renderer
20382037*
20392038* @method _renderWebGL
2040- * @param renderSession {RenderSession}
2039+ * @param renderSession {RenderSession}
20412040* @private
20422041*/
20432042PIXI.Sprite.prototype._renderWebGL = function(renderSession)
20442043{
20452044 // if the sprite is not visible or the alpha is 0 then no need to render this element
20462045 if(!this.visible || this.alpha <= 0)return;
2047-
2046+
20482047 var i,j;
20492048
20502049 // do a quick check to see if this element has a mask or a filter.
@@ -2080,7 +2079,7 @@ PIXI.Sprite.prototype._renderWebGL = function(renderSession)
20802079
20812080 if(this._mask)renderSession.maskManager.popMask(this._mask, renderSession);
20822081 if(this._filters)renderSession.filterManager.popFilter();
2083-
2082+
20842083 spriteBatch.start();
20852084 }
20862085 else
@@ -2092,22 +2091,22 @@ PIXI.Sprite.prototype._renderWebGL = function(renderSession)
20922091 {
20932092 this.children[i]._renderWebGL(renderSession);
20942093 }
2095-
2094+
20962095 }
20972096};
20982097
20992098/**
21002099* Renders the object using the Canvas renderer
21012100*
21022101* @method _renderCanvas
2103- * @param renderSession {RenderSession}
2102+ * @param renderSession {RenderSession}
21042103* @private
21052104*/
21062105PIXI.Sprite.prototype._renderCanvas = function(renderSession)
21072106{
21082107 // If the sprite is not visible or the alpha is 0 then no need to render this element
21092108 if (this.visible === false || this.alpha === 0 || this.texture.crop.width <= 0 || this.texture.crop.height <= 0) return;
2110-
2109+
21112110 if (this.blendMode !== renderSession.currentBlendMode)
21122111 {
21132112 renderSession.currentBlendMode = this.blendMode;
@@ -2164,7 +2163,7 @@ PIXI.Sprite.prototype._renderCanvas = function(renderSession)
21642163 if (this.cachedTint !== this.tint)
21652164 {
21662165 this.cachedTint = this.tint;
2167-
2166+
21682167 // TODO clean up caching - how to clean up the caches?
21692168 this.tintedTexture = PIXI.CanvasTinter.getTintedTexture(this, this.tint);
21702169 }
@@ -2662,7 +2661,7 @@ PIXI.Text.prototype.updateText = function()
26622661 this.context.strokeStyle = this.style.stroke;
26632662 this.context.lineWidth = this.style.strokeThickness;
26642663 this.context.textBaseline = 'alphabetic';
2665- this.context.lineJoin = 'round';
2664+ // this.context.lineJoin = 'round';
26662665
26672666 var linePositionX;
26682667 var linePositionY;
@@ -3598,7 +3597,7 @@ PIXI.EventTarget = {
35983597
35993598 //iterate the listeners
36003599 if(this._listeners && this._listeners[eventName]) {
3601- var listeners = this._listeners[eventName],
3600+ var listeners = this._listeners[eventName].slice(0) ,
36023601 length = listeners.length,
36033602 fn = listeners[0],
36043603 i;
@@ -4655,7 +4654,7 @@ PIXI.StripShader = function(gl)
46554654 'uniform sampler2D uSampler;',
46564655
46574656 'void main(void) {',
4658- ' gl_FragColor = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y));',
4657+ ' gl_FragColor = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y)) * alpha ;',
46594658 // ' gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);',//gl_FragColor * alpha;',
46604659 '}'
46614660 ];
@@ -5839,12 +5838,12 @@ PIXI.WebGLGraphicsData.prototype.upload = function()
58395838 var gl = this.gl;
58405839
58415840// this.lastIndex = graphics.graphicsData.length;
5842- this.glPoints = new Float32Array(this.points);
5841+ this.glPoints = new PIXI. Float32Array(this.points);
58435842
58445843 gl.bindBuffer(gl.ARRAY_BUFFER, this.buffer);
58455844 gl.bufferData(gl.ARRAY_BUFFER, this.glPoints, gl.STATIC_DRAW);
58465845
5847- this.glIndicies = new Uint16Array(this.indices);
5846+ this.glIndicies = new PIXI. Uint16Array(this.indices);
58485847
58495848 gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.indexBuffer);
58505849 gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, this.glIndicies, gl.STATIC_DRAW);
@@ -6319,8 +6318,8 @@ PIXI.WebGLRenderer.prototype.handleContextRestored = function()
63196318PIXI.WebGLRenderer.prototype.destroy = function()
63206319{
63216320 // remove listeners
6322- this.view.off ('webglcontextlost', this.contextLostBound);
6323- this.view.off ('webglcontextrestored', this.contextRestoredBound);
6321+ this.view.removeEventListener ('webglcontextlost', this.contextLostBound);
6322+ this.view.removeEventListener ('webglcontextrestored', this.contextRestoredBound);
63246323
63256324 PIXI.glContexts[this.glContextId] = null;
63266325
@@ -7001,15 +7000,15 @@ PIXI.WebGLSpriteBatch = function()
70017000 * @property vertices
70027001 * @type Float32Array
70037002 */
7004- this.vertices = new Float32Array(numVerts);
7003+ this.vertices = new PIXI. Float32Array(numVerts);
70057004
70067005 /**
70077006 * Holds the indices
70087007 *
70097008 * @property indices
70107009 * @type Uint16Array
70117010 */
7012- this.indices = new Uint16Array(numIndices);
7011+ this.indices = new PIXI. Uint16Array(numIndices);
70137012
70147013 /**
70157014 * @property lastIndexCount
@@ -7610,14 +7609,14 @@ PIXI.WebGLFastSpriteBatch = function(gl)
76107609 * @property vertices
76117610 * @type Float32Array
76127611 */
7613- this.vertices = new Float32Array(numVerts);
7612+ this.vertices = new PIXI. Float32Array(numVerts);
76147613
76157614 /**
76167615 * Index data
76177616 * @property indices
76187617 * @type Uint16Array
76197618 */
7620- this.indices = new Uint16Array(numIndices);
7619+ this.indices = new PIXI. Uint16Array(numIndices);
76217620
76227621 /**
76237622 * @property vertexBuffer
@@ -8386,7 +8385,7 @@ PIXI.WebGLFilterManager.prototype.initShaderBuffers = function()
83868385
83878386 // bind and upload the vertexs..
83888387 // keep a reference to the vertexFloatData..
8389- this.vertexArray = new Float32Array([0.0, 0.0,
8388+ this.vertexArray = new PIXI. Float32Array([0.0, 0.0,
83908389 1.0, 0.0,
83918390 0.0, 1.0,
83928391 1.0, 1.0]);
@@ -8395,15 +8394,15 @@ PIXI.WebGLFilterManager.prototype.initShaderBuffers = function()
83958394 gl.bufferData(gl.ARRAY_BUFFER, this.vertexArray, gl.STATIC_DRAW);
83968395
83978396 // bind and upload the uv buffer
8398- this.uvArray = new Float32Array([0.0, 0.0,
8397+ this.uvArray = new PIXI. Float32Array([0.0, 0.0,
83998398 1.0, 0.0,
84008399 0.0, 1.0,
84018400 1.0, 1.0]);
84028401
84038402 gl.bindBuffer(gl.ARRAY_BUFFER, this.uvBuffer);
84048403 gl.bufferData(gl.ARRAY_BUFFER, this.uvArray, gl.STATIC_DRAW);
84058404
8406- this.colorArray = new Float32Array([1.0, 0xFFFFFF,
8405+ this.colorArray = new PIXI. Float32Array([1.0, 0xFFFFFF,
84078406 1.0, 0xFFFFFF,
84088407 1.0, 0xFFFFFF,
84098408 1.0, 0xFFFFFF]);
@@ -10724,19 +10723,7 @@ PIXI.BaseTexture.prototype.destroy = function()
1072410723 }
1072510724 this.source = null;
1072610725
10727- // delete the webGL textures if any.
10728- for (var i = this._glTextures.length - 1; i >= 0; i--)
10729- {
10730- var glTexture = this._glTextures[i];
10731- var gl = PIXI.glContexts[i];
10732-
10733- if(gl && glTexture)
10734- {
10735- gl.deleteTexture(glTexture);
10736- }
10737- }
10738-
10739- this._glTextures.length = 0;
10726+ this.unloadFromGPU();
1074010727};
1074110728
1074210729/**
@@ -10765,6 +10752,34 @@ PIXI.BaseTexture.prototype.dirty = function()
1076510752 }
1076610753};
1076710754
10755+ /**
10756+ * Removes the base texture from the GPU, useful for managing resources on the GPU.
10757+ * Atexture is still 100% usable and will simply be reuploaded if there is a sprite on screen that is using it.
10758+ *
10759+ * @method unloadFromGPU
10760+ */
10761+ PIXI.BaseTexture.prototype.unloadFromGPU = function()
10762+ {
10763+ this.dirty();
10764+
10765+ // delete the webGL textures if any.
10766+ for (var i = this._glTextures.length - 1; i >= 0; i--)
10767+ {
10768+ var glTexture = this._glTextures[i];
10769+ var gl = PIXI.glContexts[i];
10770+
10771+ if(gl && glTexture)
10772+ {
10773+ gl.deleteTexture(glTexture);
10774+ }
10775+
10776+ }
10777+
10778+ this._glTextures.length = 0;
10779+
10780+ this.dirty();
10781+ };
10782+
1076810783/**
1076910784 * Helper function that creates a base texture from the given image url.
1077010785 * If the image is not in the base texture cache it will be created and loaded.
@@ -11413,6 +11428,9 @@ PIXI.RenderTexture.prototype.renderCanvas = function(displayObject, matrix, clea
1141311428 var wt = displayObject.worldTransform;
1141411429 wt.identity();
1141511430 if(matrix)wt.append(matrix);
11431+
11432+ // setWorld Alpha to ensure that the object is renderer at full opacity
11433+ displayObject.worldAlpha = 1;
1141611434
1141711435 // Time to update all the children of the displayObject with the new matrix..
1141811436 var children = displayObject.children;
@@ -11606,7 +11624,7 @@ PIXI.AbstractFilter.prototype.apply = function(frameBuffer)
1160611624*
1160711625* Phaser - http://phaser.io
1160811626*
11609- * v2.1.4 "Bethal" - Built: Sat Nov 08 2014 19:03:01
11627+ * v2.2.0 "Bethal" - Built: Sat Nov 08 2014 19:24:51
1161011628*
1161111629* By Richard Davey http://www.photonstorm.com @photonstorm
1161211630*
@@ -11649,7 +11667,7 @@ PIXI.AbstractFilter.prototype.apply = function(frameBuffer)
1164911667*/
1165011668var Phaser = Phaser || {
1165111669
11652- VERSION: '2.1.4 -dev',
11670+ VERSION: '2.2.0 -dev',
1165311671 GAMES: [],
1165411672
1165511673 AUTO: 0,
@@ -16319,7 +16337,7 @@ PIXI.Graphics.prototype._renderWebGL = function(renderSession)
1631916337 this.dirty = false;
1632016338 }
1632116339
16322- this._cachedSprite.alpha = this.alpha ;
16340+ this._cachedSprite.worldAlpha = this.worldAlpha ;
1632316341 PIXI.Sprite.prototype._renderWebGL.call(this._cachedSprite, renderSession);
1632416342
1632516343 return;
0 commit comments