Skip to content

Commit

Permalink
Merge branch 'dev-render-texture-masking' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
GoodBoyDigital committed Apr 13, 2014
2 parents 7c1c6a9 + 559a9fa commit 845edbf
Show file tree
Hide file tree
Showing 10 changed files with 119 additions and 86 deletions.
94 changes: 44 additions & 50 deletions bin/pixi.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Copyright (c) 2012-2014, Mat Groves
* http://goodboydigital.com/
*
* Compiled: 2014-03-31
* Compiled: 2014-04-11
*
* pixi.js is licensed under the MIT License.
* http://www.opensource.org/licenses/mit-license.php
Expand Down Expand Up @@ -3037,9 +3037,7 @@ PIXI.InteractionData = function()
*/
this.global = new PIXI.Point();

// this is here for legacy... but will remove
this.local = new PIXI.Point();


/**
* The target Sprite that was interacted with
*
Expand Down Expand Up @@ -3653,14 +3651,12 @@ PIXI.InteractionManager.prototype.onTouchMove = function(event)
touchData.global.x = touchEvent.clientX;
touchData.global.y = touchEvent.clientY;
}
}

var length = this.interactiveItems.length;
for (i = 0; i < length; i++)
{
var item = this.interactiveItems[i];
if(item.touchmove)
item.touchmove(touchData);
for (var j = 0; j < this.interactiveItems.length; j++)
{
var item = this.interactiveItems[j];
if(item.touchmove && item.__touchData[touchEvent.identifier]) item.touchmove(touchData);
}
}
};

Expand Down Expand Up @@ -3710,7 +3706,8 @@ PIXI.InteractionManager.prototype.onTouchStart = function(event)
//call the function!
if(item.touchstart)item.touchstart(touchData);
item.__isDown = true;
item.__touchData = touchData;
item.__touchData = item.__touchData || {};
item.__touchData[touchEvent.identifier] = touchData;

if(!item.interactiveChildren)break;
}
Expand Down Expand Up @@ -3748,11 +3745,11 @@ PIXI.InteractionManager.prototype.onTouchEnd = function(event)
for (var j = 0; j < length; j++)
{
var item = this.interactiveItems[j];
var itemTouchData = item.__touchData; // <-- Here!
item.__hit = this.hitTest(item, touchData);

if(itemTouchData === touchData)
{
if(item.__touchData && item.__touchData[touchEvent.identifier]) {

item.__hit = this.hitTest(item, item.__touchData[touchEvent.identifier]);

// so this one WAS down...
touchData.originalEvent = event || window.event;
// hitTest??
Expand Down Expand Up @@ -3780,15 +3777,8 @@ PIXI.InteractionManager.prototype.onTouchEnd = function(event)
item.__isDown = false;
}

item.__touchData = null;

}
/*
else
{
item.__touchData[touchEvent.identifier] = null;
}
*/
}
// remove the touch..
this.pool.push(touchData);
Expand Down Expand Up @@ -7885,6 +7875,11 @@ PIXI.FilterTexture = function(gl, width, height)
gl.bindFramebuffer(gl.FRAMEBUFFER, this.frameBuffer );
gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, this.texture, 0);

// required for masking a mask??
this.renderBuffer = gl.createRenderbuffer();
gl.bindRenderbuffer(gl.RENDERBUFFER, this.renderBuffer);
gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.RENDERBUFFER, this.renderBuffer);

this.resize(width, height);
};

Expand Down Expand Up @@ -7920,6 +7915,9 @@ PIXI.FilterTexture.prototype.resize = function(width, height)
gl.bindTexture(gl.TEXTURE_2D, this.texture);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);

// update the stencil buffer width and height
gl.bindRenderbuffer(gl.RENDERBUFFER, this.renderBuffer);
gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_STENCIL, width, height);
};

/**
Expand Down Expand Up @@ -8963,7 +8961,7 @@ PIXI.Graphics = function()
/**
* the bounds' padding used for bounds calculation
*
* @property bounds
* @property boundsPadding
* @type Number
*/
this.boundsPadding = 10;
Expand Down Expand Up @@ -9522,7 +9520,9 @@ PIXI.Graphics.ELIP = 3;
*/
PIXI.Strip = function(texture, width, height)
{
PIXI.DisplayObjectContainer.call( this );
PIXI.Sprite.call( this, texture );
this.width =width;
this.height = height;
this.texture = texture;
this.blendMode = PIXI.blendModes.NORMAL;

Expand Down Expand Up @@ -9565,10 +9565,11 @@ PIXI.Strip = function(texture, width, height)
this.indices = new Uint16Array()
*/

this.width = width;
this.height = height;
// this.width = width;
// this.height = height;

// load the texture!

if(texture.baseTexture.hasLoaded)
{
this.width = this.texture.frame.width;
Expand All @@ -9585,7 +9586,7 @@ PIXI.Strip = function(texture, width, height)
};

// constructor
PIXI.Strip.prototype = Object.create(PIXI.DisplayObjectContainer.prototype);
PIXI.Strip.prototype = Object.create(PIXI.Sprite.prototype);
PIXI.Strip.prototype.constructor = PIXI.Strip;

/*
Expand All @@ -9595,6 +9596,8 @@ PIXI.Strip.prototype.constructor = PIXI.Strip;
* @param texture {Texture} the texture that will be used
* @private
*/

/*
PIXI.Strip.prototype.setTexture = function(texture)
{
//TODO SET THE TEXTURES
Expand All @@ -9606,6 +9609,7 @@ PIXI.Strip.prototype.setTexture = function(texture)
this.height = texture.frame.height;
this.updateFrame = true;
};
*/

/**
* When the texture is updated, this event will fire to update the scale and frame
Expand All @@ -9614,6 +9618,7 @@ PIXI.Strip.prototype.setTexture = function(texture)
* @param event
* @private
*/

PIXI.Strip.prototype.onTextureUpdate = function()
{
this.updateFrame = true;
Expand Down Expand Up @@ -11828,7 +11833,7 @@ PIXI.BaseTexture = function(source, scaleMode)

if(!source)return;

if(this.source.complete || this.source.getContext)
if((this.source.complete || this.source.getContext) && this.source.width && this.source.height)
{
this.hasLoaded = true;
this.width = this.source.width;
Expand Down Expand Up @@ -11906,7 +11911,7 @@ PIXI.BaseTexture.fromImage = function(imageUrl, crossorigin, scaleMode)
{
var baseTexture = PIXI.BaseTextureCache[imageUrl];

if(crossorigin === undefined)crossorigin = true;
if(crossorigin === undefined && imageUrl.indexOf('data:') === -1) crossorigin = true;

if(!baseTexture)
{
Expand Down Expand Up @@ -12660,24 +12665,14 @@ PIXI.JsonLoader.prototype.load = function () {
this.ajaxRequest = new window.ActiveXObject('Microsoft.XMLHTTP');
}




// this.ajaxRequest = new PIXI.AjaxRequest(this.crossorigin);
var scope = this;




this.ajaxRequest.onload = function () {
scope.onJSONLoaded();
};

// this.ajaxRequest.open('GET', this.url, true);
// if (this.ajaxRequest.overrideMimeType) this.ajaxRequest.overrideMimeType('application/json');
// this.ajaxRequest.send(null);
this.ajaxRequest.open('GET',this.url,true);

this.ajaxRequest.open('GET',this.url,false);
this.ajaxRequest.send();
};

Expand All @@ -12688,8 +12683,13 @@ PIXI.JsonLoader.prototype.load = function () {
* @private
*/
PIXI.JsonLoader.prototype.onJSONLoaded = function () {
// if (this.ajaxRequest.readyState === 4) {
// if (this.ajaxRequest.status === 200 || window.location.protocol.indexOf('http') === -1) {

if(this.ajaxRequest.status !== 200)
{
this.onError();
return;
}

this.json = JSON.parse(this.ajaxRequest.responseText);

if(this.json.frames)
Expand Down Expand Up @@ -12743,12 +12743,6 @@ PIXI.JsonLoader.prototype.onJSONLoaded = function () {
{
this.onLoaded();
}
// }
// else
//{
// this.onError();
// / }
// }
};

/**
Expand Down
2 changes: 1 addition & 1 deletion bin/pixi.dev.js.map

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions bin/pixi.js

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions src/pixi/InteractionData.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ PIXI.InteractionData = function()
*/
this.global = new PIXI.Point();

// this is here for legacy... but will remove
this.local = new PIXI.Point();


/**
* The target Sprite that was interacted with
*
Expand Down
2 changes: 1 addition & 1 deletion src/pixi/InteractionManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ PIXI.InteractionManager.prototype.onTouchStart = function(event)
//call the function!
if(item.touchstart)item.touchstart(touchData);
item.__isDown = true;
item.__touchData = item.__touchData || {};
item.__touchData = item.__touchData || {};
item.__touchData[touchEvent.identifier] = touchData;

if(!item.interactiveChildren)break;
Expand Down
15 changes: 11 additions & 4 deletions src/pixi/extras/Strip.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
*/
PIXI.Strip = function(texture, width, height)
{
PIXI.DisplayObjectContainer.call( this );
PIXI.Sprite.call( this, texture );
this.width =width;
this.height = height;
this.texture = texture;
this.blendMode = PIXI.blendModes.NORMAL;

Expand Down Expand Up @@ -57,10 +59,11 @@ PIXI.Strip = function(texture, width, height)
this.indices = new Uint16Array()
*/

this.width = width;
this.height = height;
// this.width = width;
// this.height = height;

// load the texture!

if(texture.baseTexture.hasLoaded)
{
this.width = this.texture.frame.width;
Expand All @@ -77,7 +80,7 @@ PIXI.Strip = function(texture, width, height)
};

// constructor
PIXI.Strip.prototype = Object.create(PIXI.DisplayObjectContainer.prototype);
PIXI.Strip.prototype = Object.create(PIXI.Sprite.prototype);
PIXI.Strip.prototype.constructor = PIXI.Strip;

/*
Expand All @@ -87,6 +90,8 @@ PIXI.Strip.prototype.constructor = PIXI.Strip;
* @param texture {Texture} the texture that will be used
* @private
*/

/*
PIXI.Strip.prototype.setTexture = function(texture)
{
//TODO SET THE TEXTURES
Expand All @@ -98,6 +103,7 @@ PIXI.Strip.prototype.setTexture = function(texture)
this.height = texture.frame.height;
this.updateFrame = true;
};
*/

/**
* When the texture is updated, this event will fire to update the scale and frame
Expand All @@ -106,6 +112,7 @@ PIXI.Strip.prototype.setTexture = function(texture)
* @param event
* @private
*/

PIXI.Strip.prototype.onTextureUpdate = function()
{
this.updateFrame = true;
Expand Down
27 changes: 8 additions & 19 deletions src/pixi/loaders/JsonLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,24 +76,14 @@ PIXI.JsonLoader.prototype.load = function () {
this.ajaxRequest = new window.ActiveXObject('Microsoft.XMLHTTP');
}




// this.ajaxRequest = new PIXI.AjaxRequest(this.crossorigin);
var scope = this;




this.ajaxRequest.onload = function () {
scope.onJSONLoaded();
};

// this.ajaxRequest.open('GET', this.url, true);
// if (this.ajaxRequest.overrideMimeType) this.ajaxRequest.overrideMimeType('application/json');
// this.ajaxRequest.send(null);
this.ajaxRequest.open('GET',this.url,true);

this.ajaxRequest.open('GET',this.url,false);
this.ajaxRequest.send();
};

Expand All @@ -104,8 +94,13 @@ PIXI.JsonLoader.prototype.load = function () {
* @private
*/
PIXI.JsonLoader.prototype.onJSONLoaded = function () {
// if (this.ajaxRequest.readyState === 4) {
// if (this.ajaxRequest.status === 200 || window.location.protocol.indexOf('http') === -1) {

if(this.ajaxRequest.status !== 200)
{
this.onError();
return;
}

this.json = JSON.parse(this.ajaxRequest.responseText);

if(this.json.frames)
Expand Down Expand Up @@ -159,12 +154,6 @@ PIXI.JsonLoader.prototype.onJSONLoaded = function () {
{
this.onLoaded();
}
// }
// else
//{
// this.onError();
// / }
// }
};

/**
Expand Down
Loading

0 comments on commit 845edbf

Please sign in to comment.