Published files

This commit is contained in:
Mat Groves 2014-02-04 09:01:11 +00:00
parent e78a82fa34
commit 597e2b129e
2 changed files with 157 additions and 139 deletions

View file

@ -4,7 +4,7 @@
* Copyright (c) 2012-2014, Mat Groves * Copyright (c) 2012-2014, Mat Groves
* http://goodboydigital.com/ * http://goodboydigital.com/
* *
* Compiled: 2014-02-02 * Compiled: 2014-02-04
* *
* pixi.js is licensed under the MIT License. * pixi.js is licensed under the MIT License.
* http://www.opensource.org/licenses/mit-license.php * http://www.opensource.org/licenses/mit-license.php
@ -911,6 +911,9 @@ PIXI.DisplayObject.prototype.updateTransform = function()
// TODO OPTIMIZE THIS!! with dirty // TODO OPTIMIZE THIS!! with dirty
if(this.rotation !== this.rotationCache) if(this.rotation !== this.rotationCache)
{ {
if(isNaN(parseFloat(this.rotation)))
throw new Error('DisplayObject rotation values must be numeric.');
this.rotationCache = this.rotation; this.rotationCache = this.rotation;
this._sr = Math.sin(this.rotation); this._sr = Math.sin(this.rotation);
this._cr = Math.cos(this.rotation); this._cr = Math.cos(this.rotation);
@ -1044,6 +1047,7 @@ Object.defineProperty(PIXI.DisplayObject.prototype, 'y', {
this.position.y = value; this.position.y = value;
} }
}); });
/** /**
* @author Mat Groves http://matgroves.com/ @Doormat23 * @author Mat Groves http://matgroves.com/ @Doormat23
*/ */
@ -2550,6 +2554,8 @@ PIXI.BitmapText = function(text, style)
{ {
PIXI.DisplayObjectContainer.call(this); PIXI.DisplayObjectContainer.call(this);
this._pool = [];
this.setText(text); this.setText(text);
this.setStyle(style); this.setStyle(style);
this.updateText(); this.updateText();
@ -2655,13 +2661,28 @@ PIXI.BitmapText.prototype.updateText = function()
lineAlignOffsets.push(alignOffset); lineAlignOffsets.push(alignOffset);
} }
for(i = 0; i < chars.length; i++) var lenChildren = this.children.length;
var lenChars = chars.length;
for(i = 0; i < lenChars; i++)
{ {
var c = new PIXI.Sprite(chars[i].texture); //PIXI.Sprite.fromFrame(chars[i].charCode); var c = i < lenChildren ? this.children[i] : this._pool.pop(); // get old child if have. if not - take from pool.
if (c) c.setTexture(chars[i].texture); // check if got one before.
else c = new PIXI.Sprite(chars[i].texture); // if no create new one.
c.position.x = (chars[i].position.x + lineAlignOffsets[chars[i].line]) * scale; c.position.x = (chars[i].position.x + lineAlignOffsets[chars[i].line]) * scale;
c.position.y = chars[i].position.y * scale; c.position.y = chars[i].position.y * scale;
c.scale.x = c.scale.y = scale; c.scale.x = c.scale.y = scale;
this.addChild(c); if (!c.parent) this.addChild(c);
}
// remove unnecessary children.
// and put their into the pool.
while(this.children.length > lenChars)
{
var child = this.getChildAt(this.children.length - 1);
this._pool.push(child);
this.removeChild(child);
} }
this.width = maxLineWidth * scale; this.width = maxLineWidth * scale;
@ -2678,12 +2699,7 @@ PIXI.BitmapText.prototype.updateTransform = function()
{ {
if(this.dirty) if(this.dirty)
{ {
while(this.children.length > 0)
{
this.removeChild(this.getChildAt(0));
}
this.updateText(); this.updateText();
this.dirty = false; this.dirty = false;
} }
@ -2817,6 +2833,8 @@ PIXI.InteractionManager = function(stage)
this.last = 0; this.last = 0;
this.currentCursorStyle = 'inherit'; this.currentCursorStyle = 'inherit';
this.mouseOut = false;
}; };
// constructor // constructor
@ -3142,7 +3160,6 @@ PIXI.InteractionManager.prototype.onMouseOut = function()
for (var i = 0; i < length; i++) for (var i = 0; i < length; i++)
{ {
var item = this.interactiveItems[i]; var item = this.interactiveItems[i];
if(item.__isOver) if(item.__isOver)
{ {
this.mouse.target = item; this.mouse.target = item;
@ -3150,6 +3167,12 @@ PIXI.InteractionManager.prototype.onMouseOut = function()
item.__isOver = false; item.__isOver = false;
} }
} }
this.mouseOut = true;
// move the mouse to an impossible position
this.mouse.global.x = -10000;
this.mouse.global.y = -10000;
}; };
/** /**
@ -6489,6 +6512,9 @@ PIXI.WebGLSpriteBatch.prototype.renderTilingSprite = function(tilingSprite)
var uvs = tilingSprite._uvs; var uvs = tilingSprite._uvs;
tilingSprite.tilePosition.x %= texture.baseTexture.width;
tilingSprite.tilePosition.y %= texture.baseTexture.height;
var offsetX = tilingSprite.tilePosition.x/texture.baseTexture.width; var offsetX = tilingSprite.tilePosition.x/texture.baseTexture.width;
var offsetY = tilingSprite.tilePosition.y/texture.baseTexture.height; var offsetY = tilingSprite.tilePosition.y/texture.baseTexture.height;
@ -9679,6 +9705,10 @@ PIXI.TilingSprite.prototype._renderCanvas = function(renderSession)
var tilePosition = this.tilePosition; var tilePosition = this.tilePosition;
var tileScale = this.tileScale; var tileScale = this.tileScale;
tilePosition.x %= this.tilingTexture.baseTexture.width;
tilePosition.y %= this.tilingTexture.baseTexture.height;
// console.log(tileScale.x) // console.log(tileScale.x)
// offset // offset
context.scale(tileScale.x,tileScale.y); context.scale(tileScale.x,tileScale.y);
@ -11369,9 +11399,7 @@ PIXI.BaseTexture = function(source, scaleMode)
if(!source)return; if(!source)return;
if(this.source instanceof Image || this.source instanceof HTMLImageElement) if(this.source.complete || this.source.getContext)
{
if(this.source.complete)
{ {
this.hasLoaded = true; this.hasLoaded = true;
this.width = this.source.width; this.width = this.source.width;
@ -11395,15 +11423,6 @@ PIXI.BaseTexture = function(source, scaleMode)
}; };
//this.image.src = imageUrl; //this.image.src = imageUrl;
} }
}
else
{
this.hasLoaded = true;
this.width = this.source.width;
this.height = this.source.height;
PIXI.texturesToUpdate.push(this);
}
this.imageUrl = null; this.imageUrl = null;
this._powerOf2 = false; this._powerOf2 = false;
@ -11425,9 +11444,8 @@ PIXI.BaseTexture.prototype.constructor = PIXI.BaseTexture;
*/ */
PIXI.BaseTexture.prototype.destroy = function() PIXI.BaseTexture.prototype.destroy = function()
{ {
if(this.source instanceof Image) if(this.imageUrl)
{ {
if (this.imageUrl in PIXI.BaseTextureCache)
delete PIXI.BaseTextureCache[this.imageUrl]; delete PIXI.BaseTextureCache[this.imageUrl];
this.imageUrl = null; this.imageUrl = null;
this.source.src = null; this.source.src = null;
@ -12173,7 +12191,7 @@ PIXI.JsonLoader.prototype.constructor = PIXI.JsonLoader;
* @method load * @method load
*/ */
PIXI.JsonLoader.prototype.load = function () { PIXI.JsonLoader.prototype.load = function () {
this.ajaxRequest = new PIXI.AjaxRequest(); this.ajaxRequest = new PIXI.AjaxRequest(this.crossorigin);
var scope = this; var scope = this;
this.ajaxRequest.onreadystatechange = function () { this.ajaxRequest.onreadystatechange = function () {
scope.onJSONLoaded(); scope.onJSONLoaded();

File diff suppressed because one or more lines are too long