Docs updated

Fixed issue where alpha not being set correctly in canvas spriteBatch
Fixed issue where previous stage events did not get removed correctly
This commit is contained in:
Mat Groves 2014-01-28 00:08:50 +00:00
parent 9dbf8b47c1
commit 847eb6c48e
140 changed files with 12651 additions and 2435 deletions

View file

@ -19,7 +19,7 @@
</div>
<div class="yui3-u-1-4 version">
<em>API Docs for: 1.4.0</em>
<em>API Docs for: 1.4.3</em>
</div>
</div>
<div id="bd" class="yui3-g">
@ -73,6 +73,8 @@
<li><a href="../classes/DisplayObjectContainer.html">DisplayObjectContainer</a></li>
<li><a href="../classes/DotScreenFilter.html">DotScreenFilter</a></li>
<li><a href="../classes/Ellipse.html">Ellipse</a></li>
<li><a href="../classes/EventTarget.html">EventTarget</a></li>
@ -91,6 +93,8 @@
<li><a href="../classes/PixelateFilter.html">PixelateFilter</a></li>
<li><a href="../classes/PIXI.PixiFastShader.html">PIXI.PixiFastShader</a></li>
<li><a href="../classes/PIXI.PixiShader.html">PIXI.PixiShader</a></li>
<li><a href="../classes/Point.html">Point</a></li>
@ -115,9 +119,9 @@
<li><a href="../classes/Spine.html">Spine</a></li>
<li><a href="../classes/SpriteSheetLoader.html">SpriteSheetLoader</a></li>
<li><a href="../classes/Sprite.html">Sprite</a></li>
<li><a href="../classes/Sprite™.html">Sprite™</a></li>
<li><a href="../classes/SpriteSheetLoader.html">SpriteSheetLoader</a></li>
<li><a href="../classes/Stage.html">Stage</a></li>
@ -127,6 +131,8 @@
<li><a href="../classes/TilingSprite.html">TilingSprite</a></li>
<li><a href="../classes/TwistFilter.html">TwistFilter</a></li>
<li><a href="../classes/WebGLRenderer.html">WebGLRenderer</a></li>
</ul>
@ -195,8 +201,6 @@ PIXI.TilingSprite = function(texture, width, height)
this.width = width || 100;
this.height = height || 100;
texture.baseTexture._powerOf2 = true;
/**
* The scaling of the image that is being tiled
*
@ -205,6 +209,9 @@ PIXI.TilingSprite = function(texture, width, height)
*/
this.tileScale = new PIXI.Point(1,1);
this.tileScaleOffset = new PIXI.Point(1,1);
/**
* The offset position of the image that is being tiled
*
@ -225,7 +232,7 @@ PIXI.TilingSprite.prototype.constructor = PIXI.TilingSprite;
/**
* The width of the sprite, setting this will actually modify the scale to acheive the value set
* The width of the sprite, setting this will actually modify the scale to achieve the value set
*
* @property width
* @type Number
@ -241,7 +248,7 @@ Object.defineProperty(PIXI.TilingSprite.prototype, &#x27;width&#x27;, {
});
/**
* The height of the TilingSprite, setting this will actually modify the scale to acheive the value set
* The height of the TilingSprite, setting this will actually modify the scale to achieve the value set
*
* @property height
* @type Number
@ -258,9 +265,9 @@ Object.defineProperty(PIXI.TilingSprite.prototype, &#x27;height&#x27;, {
PIXI.TilingSprite.prototype.onTextureUpdate = function()
{
// so if _width is 0 then width was not set..
//if(this._width)this.scale.x = this._width / this.texture.frame.width;
//if(this._height)this.scale.y = this._height / this.texture.frame.height;
// alert(this._width)
//console.log(&quot;HI MUM&quot;)
this.updateFrame = true;
};
@ -276,7 +283,7 @@ PIXI.TilingSprite.prototype._renderWebGL = function(renderSession)
if(this.mask)
{
renderSession.spriteBatch.stop();
renderSession.maskManager.pushMask(this.mask, renderSession.projection);
renderSession.maskManager.pushMask(this.mask, renderSession);
renderSession.spriteBatch.start();
}
@ -286,8 +293,8 @@ PIXI.TilingSprite.prototype._renderWebGL = function(renderSession)
renderSession.filterManager.pushFilter(this._filterBlock);
}
renderSession.spriteBatch.renderTilingSprite(this);
if(!this.tilingTexture)this.generateTilingTexture(true);
else renderSession.spriteBatch.renderTilingSprite(this);
// simple render children!
for(i=0,j=this.children.length; i&lt;j; i++)
@ -298,13 +305,14 @@ PIXI.TilingSprite.prototype._renderWebGL = function(renderSession)
renderSession.spriteBatch.stop();
if(this.filters)renderSession.filterManager.popFilter();
if(this.mask)renderSession.maskManager.popMask(renderSession.projection);
if(this.mask)renderSession.maskManager.popMask(renderSession);
renderSession.spriteBatch.start();
}
else
{
renderSession.spriteBatch.renderTilingSprite(this);
if(!this.tilingTexture)this.generateTilingTexture(true);
else renderSession.spriteBatch.renderTilingSprite(this);
// simple render children!
for(i=0,j=this.children.length; i&lt;j; i++)
@ -314,24 +322,38 @@ PIXI.TilingSprite.prototype._renderWebGL = function(renderSession)
}
};
PIXI.TilingSprite.prototype._renderCanvas = function(renderSession)
{
if(this.visible === false || this.alpha === 0)return;
var context = renderSession.context;
if(this._mask)
{
renderSession.maskManager.pushMask(this._mask, context);
}
context.globalAlpha = this.worldAlpha;
var transform = this.worldTransform;
// alow for trimming
// allow for trimming
context.setTransform(transform[0], transform[3], transform[1], transform[4], transform[2], transform[5]);
if(!this.__tilePattern)
this.__tilePattern = context.createPattern(this.texture.baseTexture.source, &#x27;repeat&#x27;);
{
this.generateTilingTexture(false);
if(this.tilingTexture)
{
this.__tilePattern = context.createPattern(this.tilingTexture.baseTexture.source, &#x27;repeat&#x27;);
}
}
// check blend mode
if(this.blendMode !== renderSession.currentBlendMode)
@ -344,7 +366,7 @@ PIXI.TilingSprite.prototype._renderCanvas = function(renderSession)
var tilePosition = this.tilePosition;
var tileScale = this.tileScale;
// console.log(tileScale.x)
// offset
context.scale(tileScale.x,tileScale.y);
context.translate(tilePosition.x, tilePosition.y);
@ -356,6 +378,11 @@ PIXI.TilingSprite.prototype._renderCanvas = function(renderSession)
context.translate(-tilePosition.x, -tilePosition.y);
context.closePath();
if(this._mask)
{
renderSession.maskManager.popMask(renderSession.context);
}
};
PIXI.TilingSprite.prototype.getBounds = function()
@ -425,11 +452,73 @@ PIXI.TilingSprite.prototype.getBounds = function()
bounds.y = minY;
bounds.height = maxY - minY;
// store a refferance so that if this function gets called again in the render cycle we do not have to recacalculate
// store a reference so that if this function gets called again in the render cycle we do not have to recalculate
this._currentBounds = bounds;
return bounds;
};
PIXI.TilingSprite.prototype.generateTilingTexture = function(forcePowerOfTwo)
{
var texture = this.texture;
if(!texture.baseTexture.hasLoaded)return;
var baseTexture = texture.baseTexture;
var frame = texture.frame;
var targetWidth, targetHeight;
// check that the frame is the same size as the base texture.
var isFrame = frame.width !== baseTexture.width || frame.height !== baseTexture.height;
this.tilingTexture = texture;
var newTextureRequired = false;
if(!forcePowerOfTwo)
{
if(isFrame)
{
targetWidth = frame.width;
targetHeight = frame.height;
newTextureRequired = true;
}
}
else
{
targetWidth = PIXI.getNextPowerOfTwo(texture.frame.width);
targetHeight = PIXI.getNextPowerOfTwo(texture.frame.height);
if(frame.width !== targetWidth &amp;&amp; frame.height !== targetHeight)newTextureRequired = true;
}
if(newTextureRequired)
{
var canvasBuffer = new PIXI.CanvasBuffer(targetWidth, targetHeight);
canvasBuffer.context.drawImage(texture.baseTexture.source,
frame.x,
frame.y,
frame.width,
frame.height,
0,
0,
targetWidth,
targetHeight);
this.tilingTexture = PIXI.Texture.fromCanvas(canvasBuffer.canvas);
this.tileScaleOffset.x = frame.width / targetWidth;
this.tileScaleOffset.y = frame.height / targetHeight;
}
this.tilingTexture.baseTexture._powerOf2 = true;
};
</pre>
</div>