mirror of
https://github.com/wassname/phaser.git
synced 2026-06-27 16:10:15 +08:00
Updated to latest Pixi build (can do away with our own local patch now).
Group.sendToBottom(child) is the handy opposite of Group.bringToTop() Group.moveUp(child) will move a child up the display list, swapping with the child above it. Group.moveDown(child) will move a child down the display list, swapping with the child below it.
This commit is contained in:
@@ -128,6 +128,9 @@ New features:
|
||||
* Brand new Grunt task - creates each core library as its own file and a combined phaser.js.
|
||||
* New build script now cleanly splits Phaser, Pixi and p2 so they are each UMD wrapped and each available in the global scope (now more requireJS friendly!).
|
||||
* phaser-no-libs.js allows you to use your own version of p2.js or pixi.js with Phaser. Warning: This is totally unsupported. If you hit bugs, you fix them yourself.
|
||||
* Group.sendToBottom(child) is the handy opposite of Group.bringToTop()
|
||||
* Group.moveUp(child) will move a child up the display list, swapping with the child above it.
|
||||
* Group.moveDown(child) will move a child down the display list, swapping with the child below it.
|
||||
|
||||
|
||||
Updates:
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
* Phaser - http://www.phaser.io
|
||||
*
|
||||
* v2.0.0 "Aes Sedai" - Built: Fri Feb 28 2014 09:11:13
|
||||
* v2.0.0 "Aes Sedai" - Built: Fri Feb 28 2014 18:53:23
|
||||
*
|
||||
* By Richard Davey http://www.photonstorm.com @photonstorm
|
||||
*
|
||||
@@ -363,66 +363,6 @@ Phaser.Utils = {
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Converts a hex color number to an [R, G, B] array
|
||||
*
|
||||
* @method hex2rgb
|
||||
* @param hex {Number}
|
||||
PIXI.hex2rgb = function(hex) {
|
||||
return [(hex >> 16 & 0xFF) / 255, ( hex >> 8 & 0xFF) / 255, (hex & 0xFF)/ 255];
|
||||
};
|
||||
*/
|
||||
|
||||
/**
|
||||
* Converts a color as an [R, G, B] array to a hex number
|
||||
*
|
||||
* @method rgb2hex
|
||||
* @param rgb {Array}
|
||||
PIXI.rgb2hex = function(rgb) {
|
||||
return ((rgb[0]*255 << 16) + (rgb[1]*255 << 8) + rgb[2]*255);
|
||||
};
|
||||
*/
|
||||
|
||||
/**
|
||||
* Checks whether the Canvas BlendModes are supported by the current browser
|
||||
*
|
||||
* @method canUseNewCanvasBlendModes
|
||||
* @return {Boolean} whether they are supported
|
||||
PIXI.canUseNewCanvasBlendModes = function()
|
||||
{
|
||||
var canvas = document.createElement('canvas');
|
||||
canvas.width = 1;
|
||||
canvas.height = 1;
|
||||
var context = canvas.getContext('2d');
|
||||
context.fillStyle = '#000';
|
||||
context.fillRect(0,0,1,1);
|
||||
context.globalCompositeOperation = 'multiply';
|
||||
context.fillStyle = '#fff';
|
||||
context.fillRect(0,0,1,1);
|
||||
return context.getImageData(0,0,1,1).data[0] === 0;
|
||||
};
|
||||
*/
|
||||
|
||||
/**
|
||||
* Given a number, this function returns the closest number that is a power of two
|
||||
* this function is taken from Starling Framework as its pretty neat ;)
|
||||
*
|
||||
* @method getNextPowerOfTwo
|
||||
* @param number {Number}
|
||||
* @return {Number} the closest number that is a power of two
|
||||
PIXI.getNextPowerOfTwo = function(number)
|
||||
{
|
||||
if (number > 0 && (number & (number - 1)) === 0) // see: http://goo.gl/D9kPj
|
||||
return number;
|
||||
else
|
||||
{
|
||||
var result = 1;
|
||||
while (result < number) result <<= 1;
|
||||
return result;
|
||||
}
|
||||
};
|
||||
*/
|
||||
|
||||
/**
|
||||
* A polyfill for Function.prototype.bind
|
||||
*/
|
||||
@@ -469,7 +409,6 @@ if (!Array.isArray) {
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2014 Photon Storm Ltd.
|
||||
@@ -5937,11 +5876,18 @@ Phaser.Group.prototype.addAt = function (child, index) {
|
||||
*
|
||||
* @method Phaser.Group#getAt
|
||||
* @param {number} index - The index to return the child from.
|
||||
* @return {*} The child that was found at the given index.
|
||||
* @return {*} The child that was found at the given index. If the index was out of bounds then this will return -1.
|
||||
*/
|
||||
Phaser.Group.prototype.getAt = function (index) {
|
||||
|
||||
return this.getChildAt(index);
|
||||
if (index < 0 || index > this.children.length)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.getChildAt(index);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6076,7 +6022,7 @@ Phaser.Group.prototype.swap = function (child1, child2) {
|
||||
*/
|
||||
Phaser.Group.prototype.bringToTop = function (child) {
|
||||
|
||||
if (child.parent === this)
|
||||
if (child.parent === this && this.getIndex(child) < this.children.length)
|
||||
{
|
||||
this.remove(child);
|
||||
this.add(child);
|
||||
@@ -6086,6 +6032,73 @@ Phaser.Group.prototype.bringToTop = function (child) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends the given child to the bottom of this Group so it renders below all other children.
|
||||
*
|
||||
* @method Phaser.Group#sendToBottom
|
||||
* @param {*} child - The child to send to the bottom of this Group.
|
||||
* @return {*} The child that was moved.
|
||||
*/
|
||||
Phaser.Group.prototype.sendToBottom = function (child) {
|
||||
|
||||
if (child.parent === this && this.getIndex(child) > 0)
|
||||
{
|
||||
this.remove(child);
|
||||
this.addAt(child, 0);
|
||||
}
|
||||
|
||||
return child;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves the given child up one place in this Group unless it's already at the top.
|
||||
*
|
||||
* @method Phaser.Group#moveUp
|
||||
* @param {*} child - The child to move up in the Group.
|
||||
* @return {*} The child that was moved.
|
||||
*/
|
||||
Phaser.Group.prototype.moveUp = function (child) {
|
||||
|
||||
if (child.parent === this && this.getIndex(child) < this.children.length - 1)
|
||||
{
|
||||
var a = this.getIndex(child);
|
||||
var b = this.getAt(a + 1);
|
||||
|
||||
if (b)
|
||||
{
|
||||
this.swap(a, b);
|
||||
}
|
||||
}
|
||||
|
||||
return child;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves the given child down one place in this Group unless it's already at the top.
|
||||
*
|
||||
* @method Phaser.Group#moveDown
|
||||
* @param {*} child - The child to move down in the Group.
|
||||
* @return {*} The child that was moved.
|
||||
*/
|
||||
Phaser.Group.prototype.moveDown = function (child) {
|
||||
|
||||
if (child.parent === this && this.getIndex(child) > 0)
|
||||
{
|
||||
var a = this.getIndex(child);
|
||||
var b = this.getAt(a - 1);
|
||||
|
||||
if (b)
|
||||
{
|
||||
this.swap(a, b);
|
||||
}
|
||||
}
|
||||
|
||||
return child;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the index position of the given child in this Group.
|
||||
*
|
||||
|
||||
Vendored
+7
-7
File diff suppressed because one or more lines are too long
+43
-65
@@ -2160,6 +2160,9 @@ PIXI.SpriteBatch.prototype._renderCanvas = function(renderSession)
|
||||
for (var i = 0; i < this.children.length; i++) {
|
||||
|
||||
var child = this.children[i];
|
||||
|
||||
if(!child.visible)continue;
|
||||
|
||||
var texture = child.texture;
|
||||
var frame = texture.frame;
|
||||
|
||||
@@ -3453,7 +3456,6 @@ PIXI.PixiShader = function(gl)
|
||||
'}'
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @property {number} textureCount - A local texture counter for multi-texture shaders.
|
||||
*/
|
||||
@@ -3471,7 +3473,6 @@ PIXI.PixiShader = function(gl)
|
||||
*/
|
||||
PIXI.PixiShader.prototype.init = function()
|
||||
{
|
||||
|
||||
var gl = this.gl;
|
||||
|
||||
var program = PIXI.compileProgram(gl, this.vertexSrc || PIXI.PixiShader.defaultVertexSrc, this.fragmentSrc);
|
||||
@@ -3725,7 +3726,6 @@ PIXI.PixiShader.prototype.syncUniforms = function()
|
||||
/**
|
||||
* Destroys the shader
|
||||
* @method destroy
|
||||
*
|
||||
*/
|
||||
PIXI.PixiShader.prototype.destroy = function()
|
||||
{
|
||||
@@ -3737,7 +3737,7 @@ PIXI.PixiShader.prototype.destroy = function()
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* The Default Vertex shader source
|
||||
* @property defaultVertexSrc
|
||||
* @type String
|
||||
*/
|
||||
@@ -3762,10 +3762,6 @@ PIXI.PixiShader.defaultVertexSrc = [
|
||||
'}'
|
||||
];
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author Mat Groves http://matgroves.com/ @Doormat23
|
||||
* @author Richard Davey http://www.photonstorm.com @photonstorm
|
||||
@@ -6084,6 +6080,7 @@ PIXI.WebGLFastSpriteBatch.prototype.render = function(spriteBatch)
|
||||
PIXI.WebGLFastSpriteBatch.prototype.renderSprite = function(sprite)
|
||||
{
|
||||
//sprite = children[i];
|
||||
if(!sprite.visible)return;
|
||||
|
||||
// TODO trim??
|
||||
if(sprite.texture.baseTexture !== this.currentBaseTexture)
|
||||
@@ -8429,7 +8426,7 @@ PIXI.Graphics.ELIP = 3;
|
||||
* A tiling sprite is a fast way of rendering a tiling image
|
||||
*
|
||||
* @class TilingSprite
|
||||
* @extends DisplayObjectContainer
|
||||
* @extends Sprite
|
||||
* @constructor
|
||||
* @param texture {Texture} the texture of the tiling sprite
|
||||
* @param width {Number} the width of the tiling sprite
|
||||
@@ -8446,6 +8443,7 @@ PIXI.TilingSprite = function(texture, width, height)
|
||||
* @type Number
|
||||
*/
|
||||
this.width = width || 100;
|
||||
|
||||
/**
|
||||
* The height of the tiling sprite
|
||||
*
|
||||
@@ -8599,58 +8597,46 @@ PIXI.TilingSprite.prototype._renderWebGL = function(renderSession)
|
||||
|
||||
var i,j;
|
||||
|
||||
if(this.mask || this.filters)
|
||||
if(this.mask)
|
||||
{
|
||||
if(this.mask)
|
||||
{
|
||||
renderSession.spriteBatch.stop();
|
||||
renderSession.maskManager.pushMask(this.mask, renderSession);
|
||||
renderSession.spriteBatch.start();
|
||||
}
|
||||
|
||||
if(this.filters)
|
||||
{
|
||||
renderSession.spriteBatch.flush();
|
||||
renderSession.filterManager.pushFilter(this._filterBlock);
|
||||
}
|
||||
|
||||
if(!this.tilingTexture || this.refreshTexture)this.generateTilingTexture(true);
|
||||
else renderSession.spriteBatch.renderTilingSprite(this);
|
||||
|
||||
// simple render children!
|
||||
for(i=0,j=this.children.length; i<j; i++)
|
||||
{
|
||||
this.children[i]._renderWebGL(renderSession);
|
||||
}
|
||||
|
||||
renderSession.spriteBatch.stop();
|
||||
|
||||
if(this.filters)renderSession.filterManager.popFilter();
|
||||
if(this.mask)renderSession.maskManager.popMask(renderSession);
|
||||
|
||||
renderSession.maskManager.pushMask(this.mask, renderSession);
|
||||
renderSession.spriteBatch.start();
|
||||
}
|
||||
else
|
||||
|
||||
if(this.filters)
|
||||
{
|
||||
if(!this.tilingTexture || this.refreshTexture)
|
||||
renderSession.spriteBatch.flush();
|
||||
renderSession.filterManager.pushFilter(this._filterBlock);
|
||||
}
|
||||
|
||||
|
||||
if(!this.tilingTexture || this.refreshTexture)
|
||||
{
|
||||
this.generateTilingTexture(true);
|
||||
if(this.tilingTexture && this.tilingTexture.needsUpdate)
|
||||
{
|
||||
this.generateTilingTexture(true);
|
||||
if(this.tilingTexture.needsUpdate)
|
||||
{
|
||||
//TODO - tweaking
|
||||
PIXI.updateWebGLTexture(this.tilingTexture.baseTexture, renderSession.gl);
|
||||
this.tilingTexture.needsUpdate = false;
|
||||
// this.tilingTexture._uvs = null;
|
||||
}
|
||||
}
|
||||
else renderSession.spriteBatch.renderTilingSprite(this);
|
||||
|
||||
// simple render children!
|
||||
for(i=0,j=this.children.length; i<j; i++)
|
||||
{
|
||||
this.children[i]._renderWebGL(renderSession);
|
||||
//TODO - tweaking
|
||||
PIXI.updateWebGLTexture(this.tilingTexture.baseTexture, renderSession.gl);
|
||||
this.tilingTexture.needsUpdate = false;
|
||||
// this.tilingTexture._uvs = null;
|
||||
}
|
||||
}
|
||||
else renderSession.spriteBatch.renderTilingSprite(this);
|
||||
|
||||
|
||||
// simple render children!
|
||||
for(i=0,j=this.children.length; i<j; i++)
|
||||
{
|
||||
this.children[i]._renderWebGL(renderSession);
|
||||
}
|
||||
|
||||
renderSession.spriteBatch.stop();
|
||||
|
||||
if(this.filters)renderSession.filterManager.popFilter();
|
||||
if(this.mask)renderSession.maskManager.popMask(renderSession);
|
||||
|
||||
renderSession.spriteBatch.start();
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -8831,17 +8817,9 @@ PIXI.TilingSprite.prototype.generateTilingTexture = function(forcePowerOfTwo)
|
||||
{
|
||||
if(isFrame)
|
||||
{
|
||||
if (texture.trim)
|
||||
{
|
||||
targetWidth = texture.trim.width;
|
||||
targetHeight = texture.trim.height;
|
||||
}
|
||||
else
|
||||
{
|
||||
targetWidth = frame.width;
|
||||
targetHeight = frame.height;
|
||||
}
|
||||
|
||||
targetWidth = frame.width;
|
||||
targetHeight = frame.height;
|
||||
|
||||
newTextureRequired = true;
|
||||
|
||||
}
|
||||
@@ -8874,7 +8852,7 @@ PIXI.TilingSprite.prototype.generateTilingTexture = function(forcePowerOfTwo)
|
||||
this.tilingTexture.isTiling = true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
canvasBuffer.context.drawImage(texture.baseTexture.source,
|
||||
frame.x,
|
||||
frame.y,
|
||||
|
||||
Vendored
+3
-3
File diff suppressed because one or more lines are too long
+122
-131
@@ -7,7 +7,7 @@
|
||||
*
|
||||
* Phaser - http://www.phaser.io
|
||||
*
|
||||
* v2.0.0 "Aes Sedai" - Built: Fri Feb 28 2014 09:11:13
|
||||
* v2.0.0 "Aes Sedai" - Built: Fri Feb 28 2014 18:53:23
|
||||
*
|
||||
* By Richard Davey http://www.photonstorm.com @photonstorm
|
||||
*
|
||||
@@ -12850,6 +12850,9 @@ PIXI.SpriteBatch.prototype._renderCanvas = function(renderSession)
|
||||
for (var i = 0; i < this.children.length; i++) {
|
||||
|
||||
var child = this.children[i];
|
||||
|
||||
if(!child.visible)continue;
|
||||
|
||||
var texture = child.texture;
|
||||
var frame = texture.frame;
|
||||
|
||||
@@ -14143,7 +14146,6 @@ PIXI.PixiShader = function(gl)
|
||||
'}'
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @property {number} textureCount - A local texture counter for multi-texture shaders.
|
||||
*/
|
||||
@@ -14161,7 +14163,6 @@ PIXI.PixiShader = function(gl)
|
||||
*/
|
||||
PIXI.PixiShader.prototype.init = function()
|
||||
{
|
||||
|
||||
var gl = this.gl;
|
||||
|
||||
var program = PIXI.compileProgram(gl, this.vertexSrc || PIXI.PixiShader.defaultVertexSrc, this.fragmentSrc);
|
||||
@@ -14415,7 +14416,6 @@ PIXI.PixiShader.prototype.syncUniforms = function()
|
||||
/**
|
||||
* Destroys the shader
|
||||
* @method destroy
|
||||
*
|
||||
*/
|
||||
PIXI.PixiShader.prototype.destroy = function()
|
||||
{
|
||||
@@ -14427,7 +14427,7 @@ PIXI.PixiShader.prototype.destroy = function()
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* The Default Vertex shader source
|
||||
* @property defaultVertexSrc
|
||||
* @type String
|
||||
*/
|
||||
@@ -14452,10 +14452,6 @@ PIXI.PixiShader.defaultVertexSrc = [
|
||||
'}'
|
||||
];
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author Mat Groves http://matgroves.com/ @Doormat23
|
||||
* @author Richard Davey http://www.photonstorm.com @photonstorm
|
||||
@@ -16774,6 +16770,7 @@ PIXI.WebGLFastSpriteBatch.prototype.render = function(spriteBatch)
|
||||
PIXI.WebGLFastSpriteBatch.prototype.renderSprite = function(sprite)
|
||||
{
|
||||
//sprite = children[i];
|
||||
if(!sprite.visible)return;
|
||||
|
||||
// TODO trim??
|
||||
if(sprite.texture.baseTexture !== this.currentBaseTexture)
|
||||
@@ -19119,7 +19116,7 @@ PIXI.Graphics.ELIP = 3;
|
||||
* A tiling sprite is a fast way of rendering a tiling image
|
||||
*
|
||||
* @class TilingSprite
|
||||
* @extends DisplayObjectContainer
|
||||
* @extends Sprite
|
||||
* @constructor
|
||||
* @param texture {Texture} the texture of the tiling sprite
|
||||
* @param width {Number} the width of the tiling sprite
|
||||
@@ -19136,6 +19133,7 @@ PIXI.TilingSprite = function(texture, width, height)
|
||||
* @type Number
|
||||
*/
|
||||
this.width = width || 100;
|
||||
|
||||
/**
|
||||
* The height of the tiling sprite
|
||||
*
|
||||
@@ -19289,58 +19287,46 @@ PIXI.TilingSprite.prototype._renderWebGL = function(renderSession)
|
||||
|
||||
var i,j;
|
||||
|
||||
if(this.mask || this.filters)
|
||||
if(this.mask)
|
||||
{
|
||||
if(this.mask)
|
||||
{
|
||||
renderSession.spriteBatch.stop();
|
||||
renderSession.maskManager.pushMask(this.mask, renderSession);
|
||||
renderSession.spriteBatch.start();
|
||||
}
|
||||
|
||||
if(this.filters)
|
||||
{
|
||||
renderSession.spriteBatch.flush();
|
||||
renderSession.filterManager.pushFilter(this._filterBlock);
|
||||
}
|
||||
|
||||
if(!this.tilingTexture || this.refreshTexture)this.generateTilingTexture(true);
|
||||
else renderSession.spriteBatch.renderTilingSprite(this);
|
||||
|
||||
// simple render children!
|
||||
for(i=0,j=this.children.length; i<j; i++)
|
||||
{
|
||||
this.children[i]._renderWebGL(renderSession);
|
||||
}
|
||||
|
||||
renderSession.spriteBatch.stop();
|
||||
|
||||
if(this.filters)renderSession.filterManager.popFilter();
|
||||
if(this.mask)renderSession.maskManager.popMask(renderSession);
|
||||
|
||||
renderSession.maskManager.pushMask(this.mask, renderSession);
|
||||
renderSession.spriteBatch.start();
|
||||
}
|
||||
else
|
||||
|
||||
if(this.filters)
|
||||
{
|
||||
if(!this.tilingTexture || this.refreshTexture)
|
||||
renderSession.spriteBatch.flush();
|
||||
renderSession.filterManager.pushFilter(this._filterBlock);
|
||||
}
|
||||
|
||||
|
||||
if(!this.tilingTexture || this.refreshTexture)
|
||||
{
|
||||
this.generateTilingTexture(true);
|
||||
if(this.tilingTexture && this.tilingTexture.needsUpdate)
|
||||
{
|
||||
this.generateTilingTexture(true);
|
||||
if(this.tilingTexture.needsUpdate)
|
||||
{
|
||||
//TODO - tweaking
|
||||
PIXI.updateWebGLTexture(this.tilingTexture.baseTexture, renderSession.gl);
|
||||
this.tilingTexture.needsUpdate = false;
|
||||
// this.tilingTexture._uvs = null;
|
||||
}
|
||||
}
|
||||
else renderSession.spriteBatch.renderTilingSprite(this);
|
||||
|
||||
// simple render children!
|
||||
for(i=0,j=this.children.length; i<j; i++)
|
||||
{
|
||||
this.children[i]._renderWebGL(renderSession);
|
||||
//TODO - tweaking
|
||||
PIXI.updateWebGLTexture(this.tilingTexture.baseTexture, renderSession.gl);
|
||||
this.tilingTexture.needsUpdate = false;
|
||||
// this.tilingTexture._uvs = null;
|
||||
}
|
||||
}
|
||||
else renderSession.spriteBatch.renderTilingSprite(this);
|
||||
|
||||
|
||||
// simple render children!
|
||||
for(i=0,j=this.children.length; i<j; i++)
|
||||
{
|
||||
this.children[i]._renderWebGL(renderSession);
|
||||
}
|
||||
|
||||
renderSession.spriteBatch.stop();
|
||||
|
||||
if(this.filters)renderSession.filterManager.popFilter();
|
||||
if(this.mask)renderSession.maskManager.popMask(renderSession);
|
||||
|
||||
renderSession.spriteBatch.start();
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -19521,17 +19507,9 @@ PIXI.TilingSprite.prototype.generateTilingTexture = function(forcePowerOfTwo)
|
||||
{
|
||||
if(isFrame)
|
||||
{
|
||||
if (texture.trim)
|
||||
{
|
||||
targetWidth = texture.trim.width;
|
||||
targetHeight = texture.trim.height;
|
||||
}
|
||||
else
|
||||
{
|
||||
targetWidth = frame.width;
|
||||
targetHeight = frame.height;
|
||||
}
|
||||
|
||||
targetWidth = frame.width;
|
||||
targetHeight = frame.height;
|
||||
|
||||
newTextureRequired = true;
|
||||
|
||||
}
|
||||
@@ -19564,7 +19542,7 @@ PIXI.TilingSprite.prototype.generateTilingTexture = function(forcePowerOfTwo)
|
||||
this.tilingTexture.isTiling = true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
canvasBuffer.context.drawImage(texture.baseTexture.source,
|
||||
frame.x,
|
||||
frame.y,
|
||||
@@ -20287,7 +20265,7 @@ PIXI.RenderTexture.tempMatrix = new PIXI.Matrix();
|
||||
*
|
||||
* Phaser - http://www.phaser.io
|
||||
*
|
||||
* v2.0.0 "Aes Sedai" - Built: Fri Feb 28 2014 09:11:13
|
||||
* v2.0.0 "Aes Sedai" - Built: Fri Feb 28 2014 18:53:23
|
||||
*
|
||||
* By Richard Davey http://www.photonstorm.com @photonstorm
|
||||
*
|
||||
@@ -20643,66 +20621,6 @@ Phaser.Utils = {
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Converts a hex color number to an [R, G, B] array
|
||||
*
|
||||
* @method hex2rgb
|
||||
* @param hex {Number}
|
||||
PIXI.hex2rgb = function(hex) {
|
||||
return [(hex >> 16 & 0xFF) / 255, ( hex >> 8 & 0xFF) / 255, (hex & 0xFF)/ 255];
|
||||
};
|
||||
*/
|
||||
|
||||
/**
|
||||
* Converts a color as an [R, G, B] array to a hex number
|
||||
*
|
||||
* @method rgb2hex
|
||||
* @param rgb {Array}
|
||||
PIXI.rgb2hex = function(rgb) {
|
||||
return ((rgb[0]*255 << 16) + (rgb[1]*255 << 8) + rgb[2]*255);
|
||||
};
|
||||
*/
|
||||
|
||||
/**
|
||||
* Checks whether the Canvas BlendModes are supported by the current browser
|
||||
*
|
||||
* @method canUseNewCanvasBlendModes
|
||||
* @return {Boolean} whether they are supported
|
||||
PIXI.canUseNewCanvasBlendModes = function()
|
||||
{
|
||||
var canvas = document.createElement('canvas');
|
||||
canvas.width = 1;
|
||||
canvas.height = 1;
|
||||
var context = canvas.getContext('2d');
|
||||
context.fillStyle = '#000';
|
||||
context.fillRect(0,0,1,1);
|
||||
context.globalCompositeOperation = 'multiply';
|
||||
context.fillStyle = '#fff';
|
||||
context.fillRect(0,0,1,1);
|
||||
return context.getImageData(0,0,1,1).data[0] === 0;
|
||||
};
|
||||
*/
|
||||
|
||||
/**
|
||||
* Given a number, this function returns the closest number that is a power of two
|
||||
* this function is taken from Starling Framework as its pretty neat ;)
|
||||
*
|
||||
* @method getNextPowerOfTwo
|
||||
* @param number {Number}
|
||||
* @return {Number} the closest number that is a power of two
|
||||
PIXI.getNextPowerOfTwo = function(number)
|
||||
{
|
||||
if (number > 0 && (number & (number - 1)) === 0) // see: http://goo.gl/D9kPj
|
||||
return number;
|
||||
else
|
||||
{
|
||||
var result = 1;
|
||||
while (result < number) result <<= 1;
|
||||
return result;
|
||||
}
|
||||
};
|
||||
*/
|
||||
|
||||
/**
|
||||
* A polyfill for Function.prototype.bind
|
||||
*/
|
||||
@@ -20749,7 +20667,6 @@ if (!Array.isArray) {
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2014 Photon Storm Ltd.
|
||||
@@ -26217,11 +26134,18 @@ Phaser.Group.prototype.addAt = function (child, index) {
|
||||
*
|
||||
* @method Phaser.Group#getAt
|
||||
* @param {number} index - The index to return the child from.
|
||||
* @return {*} The child that was found at the given index.
|
||||
* @return {*} The child that was found at the given index. If the index was out of bounds then this will return -1.
|
||||
*/
|
||||
Phaser.Group.prototype.getAt = function (index) {
|
||||
|
||||
return this.getChildAt(index);
|
||||
if (index < 0 || index > this.children.length)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.getChildAt(index);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26356,7 +26280,7 @@ Phaser.Group.prototype.swap = function (child1, child2) {
|
||||
*/
|
||||
Phaser.Group.prototype.bringToTop = function (child) {
|
||||
|
||||
if (child.parent === this)
|
||||
if (child.parent === this && this.getIndex(child) < this.children.length)
|
||||
{
|
||||
this.remove(child);
|
||||
this.add(child);
|
||||
@@ -26366,6 +26290,73 @@ Phaser.Group.prototype.bringToTop = function (child) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends the given child to the bottom of this Group so it renders below all other children.
|
||||
*
|
||||
* @method Phaser.Group#sendToBottom
|
||||
* @param {*} child - The child to send to the bottom of this Group.
|
||||
* @return {*} The child that was moved.
|
||||
*/
|
||||
Phaser.Group.prototype.sendToBottom = function (child) {
|
||||
|
||||
if (child.parent === this && this.getIndex(child) > 0)
|
||||
{
|
||||
this.remove(child);
|
||||
this.addAt(child, 0);
|
||||
}
|
||||
|
||||
return child;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves the given child up one place in this Group unless it's already at the top.
|
||||
*
|
||||
* @method Phaser.Group#moveUp
|
||||
* @param {*} child - The child to move up in the Group.
|
||||
* @return {*} The child that was moved.
|
||||
*/
|
||||
Phaser.Group.prototype.moveUp = function (child) {
|
||||
|
||||
if (child.parent === this && this.getIndex(child) < this.children.length - 1)
|
||||
{
|
||||
var a = this.getIndex(child);
|
||||
var b = this.getAt(a + 1);
|
||||
|
||||
if (b)
|
||||
{
|
||||
this.swap(a, b);
|
||||
}
|
||||
}
|
||||
|
||||
return child;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves the given child down one place in this Group unless it's already at the top.
|
||||
*
|
||||
* @method Phaser.Group#moveDown
|
||||
* @param {*} child - The child to move down in the Group.
|
||||
* @return {*} The child that was moved.
|
||||
*/
|
||||
Phaser.Group.prototype.moveDown = function (child) {
|
||||
|
||||
if (child.parent === this && this.getIndex(child) > 0)
|
||||
{
|
||||
var a = this.getIndex(child);
|
||||
var b = this.getAt(a - 1);
|
||||
|
||||
if (b)
|
||||
{
|
||||
this.swap(a, b);
|
||||
}
|
||||
}
|
||||
|
||||
return child;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the index position of the given child in this Group.
|
||||
*
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+5
-5
File diff suppressed because one or more lines are too long
@@ -6,7 +6,7 @@
|
||||
<title>phaser</title>
|
||||
<base href="../" />
|
||||
<script src="_site/js/jquery-2.0.3.min.js" type="text/javascript"></script>
|
||||
<script src="../dist/phaser.js" type="text/javascript"></script>
|
||||
<script src="../build/phaser.js" type="text/javascript"></script>
|
||||
<?php
|
||||
if (isset($_GET['f']))
|
||||
{
|
||||
|
||||
+77
-3
@@ -213,11 +213,18 @@ Phaser.Group.prototype.addAt = function (child, index) {
|
||||
*
|
||||
* @method Phaser.Group#getAt
|
||||
* @param {number} index - The index to return the child from.
|
||||
* @return {*} The child that was found at the given index.
|
||||
* @return {*} The child that was found at the given index. If the index was out of bounds then this will return -1.
|
||||
*/
|
||||
Phaser.Group.prototype.getAt = function (index) {
|
||||
|
||||
return this.getChildAt(index);
|
||||
if (index < 0 || index > this.children.length)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.getChildAt(index);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -352,7 +359,7 @@ Phaser.Group.prototype.swap = function (child1, child2) {
|
||||
*/
|
||||
Phaser.Group.prototype.bringToTop = function (child) {
|
||||
|
||||
if (child.parent === this)
|
||||
if (child.parent === this && this.getIndex(child) < this.children.length)
|
||||
{
|
||||
this.remove(child);
|
||||
this.add(child);
|
||||
@@ -362,6 +369,73 @@ Phaser.Group.prototype.bringToTop = function (child) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends the given child to the bottom of this Group so it renders below all other children.
|
||||
*
|
||||
* @method Phaser.Group#sendToBottom
|
||||
* @param {*} child - The child to send to the bottom of this Group.
|
||||
* @return {*} The child that was moved.
|
||||
*/
|
||||
Phaser.Group.prototype.sendToBottom = function (child) {
|
||||
|
||||
if (child.parent === this && this.getIndex(child) > 0)
|
||||
{
|
||||
this.remove(child);
|
||||
this.addAt(child, 0);
|
||||
}
|
||||
|
||||
return child;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves the given child up one place in this Group unless it's already at the top.
|
||||
*
|
||||
* @method Phaser.Group#moveUp
|
||||
* @param {*} child - The child to move up in the Group.
|
||||
* @return {*} The child that was moved.
|
||||
*/
|
||||
Phaser.Group.prototype.moveUp = function (child) {
|
||||
|
||||
if (child.parent === this && this.getIndex(child) < this.children.length - 1)
|
||||
{
|
||||
var a = this.getIndex(child);
|
||||
var b = this.getAt(a + 1);
|
||||
|
||||
if (b)
|
||||
{
|
||||
this.swap(a, b);
|
||||
}
|
||||
}
|
||||
|
||||
return child;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves the given child down one place in this Group unless it's already at the top.
|
||||
*
|
||||
* @method Phaser.Group#moveDown
|
||||
* @param {*} child - The child to move down in the Group.
|
||||
* @return {*} The child that was moved.
|
||||
*/
|
||||
Phaser.Group.prototype.moveDown = function (child) {
|
||||
|
||||
if (child.parent === this && this.getIndex(child) > 0)
|
||||
{
|
||||
var a = this.getIndex(child);
|
||||
var b = this.getAt(a - 1);
|
||||
|
||||
if (b)
|
||||
{
|
||||
this.swap(a, b);
|
||||
}
|
||||
}
|
||||
|
||||
return child;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the index position of the given child in this Group.
|
||||
*
|
||||
|
||||
@@ -109,6 +109,9 @@ PIXI.SpriteBatch.prototype._renderCanvas = function(renderSession)
|
||||
for (var i = 0; i < this.children.length; i++) {
|
||||
|
||||
var child = this.children[i];
|
||||
|
||||
if(!child.visible)continue;
|
||||
|
||||
var texture = child.texture;
|
||||
var frame = texture.frame;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* A tiling sprite is a fast way of rendering a tiling image
|
||||
*
|
||||
* @class TilingSprite
|
||||
* @extends DisplayObjectContainer
|
||||
* @extends Sprite
|
||||
* @constructor
|
||||
* @param texture {Texture} the texture of the tiling sprite
|
||||
* @param width {Number} the width of the tiling sprite
|
||||
@@ -23,6 +23,7 @@ PIXI.TilingSprite = function(texture, width, height)
|
||||
* @type Number
|
||||
*/
|
||||
this.width = width || 100;
|
||||
|
||||
/**
|
||||
* The height of the tiling sprite
|
||||
*
|
||||
@@ -176,58 +177,46 @@ PIXI.TilingSprite.prototype._renderWebGL = function(renderSession)
|
||||
|
||||
var i,j;
|
||||
|
||||
if(this.mask || this.filters)
|
||||
if(this.mask)
|
||||
{
|
||||
if(this.mask)
|
||||
{
|
||||
renderSession.spriteBatch.stop();
|
||||
renderSession.maskManager.pushMask(this.mask, renderSession);
|
||||
renderSession.spriteBatch.start();
|
||||
}
|
||||
|
||||
if(this.filters)
|
||||
{
|
||||
renderSession.spriteBatch.flush();
|
||||
renderSession.filterManager.pushFilter(this._filterBlock);
|
||||
}
|
||||
|
||||
if(!this.tilingTexture || this.refreshTexture)this.generateTilingTexture(true);
|
||||
else renderSession.spriteBatch.renderTilingSprite(this);
|
||||
|
||||
// simple render children!
|
||||
for(i=0,j=this.children.length; i<j; i++)
|
||||
{
|
||||
this.children[i]._renderWebGL(renderSession);
|
||||
}
|
||||
|
||||
renderSession.spriteBatch.stop();
|
||||
|
||||
if(this.filters)renderSession.filterManager.popFilter();
|
||||
if(this.mask)renderSession.maskManager.popMask(renderSession);
|
||||
|
||||
renderSession.maskManager.pushMask(this.mask, renderSession);
|
||||
renderSession.spriteBatch.start();
|
||||
}
|
||||
else
|
||||
|
||||
if(this.filters)
|
||||
{
|
||||
if(!this.tilingTexture || this.refreshTexture)
|
||||
renderSession.spriteBatch.flush();
|
||||
renderSession.filterManager.pushFilter(this._filterBlock);
|
||||
}
|
||||
|
||||
|
||||
if(!this.tilingTexture || this.refreshTexture)
|
||||
{
|
||||
this.generateTilingTexture(true);
|
||||
if(this.tilingTexture && this.tilingTexture.needsUpdate)
|
||||
{
|
||||
this.generateTilingTexture(true);
|
||||
if(this.tilingTexture.needsUpdate)
|
||||
{
|
||||
//TODO - tweaking
|
||||
PIXI.updateWebGLTexture(this.tilingTexture.baseTexture, renderSession.gl);
|
||||
this.tilingTexture.needsUpdate = false;
|
||||
// this.tilingTexture._uvs = null;
|
||||
}
|
||||
}
|
||||
else renderSession.spriteBatch.renderTilingSprite(this);
|
||||
|
||||
// simple render children!
|
||||
for(i=0,j=this.children.length; i<j; i++)
|
||||
{
|
||||
this.children[i]._renderWebGL(renderSession);
|
||||
//TODO - tweaking
|
||||
PIXI.updateWebGLTexture(this.tilingTexture.baseTexture, renderSession.gl);
|
||||
this.tilingTexture.needsUpdate = false;
|
||||
// this.tilingTexture._uvs = null;
|
||||
}
|
||||
}
|
||||
else renderSession.spriteBatch.renderTilingSprite(this);
|
||||
|
||||
|
||||
// simple render children!
|
||||
for(i=0,j=this.children.length; i<j; i++)
|
||||
{
|
||||
this.children[i]._renderWebGL(renderSession);
|
||||
}
|
||||
|
||||
renderSession.spriteBatch.stop();
|
||||
|
||||
if(this.filters)renderSession.filterManager.popFilter();
|
||||
if(this.mask)renderSession.maskManager.popMask(renderSession);
|
||||
|
||||
renderSession.spriteBatch.start();
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -408,17 +397,9 @@ PIXI.TilingSprite.prototype.generateTilingTexture = function(forcePowerOfTwo)
|
||||
{
|
||||
if(isFrame)
|
||||
{
|
||||
if (texture.trim)
|
||||
{
|
||||
targetWidth = texture.trim.width;
|
||||
targetHeight = texture.trim.height;
|
||||
}
|
||||
else
|
||||
{
|
||||
targetWidth = frame.width;
|
||||
targetHeight = frame.height;
|
||||
}
|
||||
|
||||
targetWidth = frame.width;
|
||||
targetHeight = frame.height;
|
||||
|
||||
newTextureRequired = true;
|
||||
|
||||
}
|
||||
@@ -451,7 +432,7 @@ PIXI.TilingSprite.prototype.generateTilingTexture = function(forcePowerOfTwo)
|
||||
this.tilingTexture.isTiling = true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
canvasBuffer.context.drawImage(texture.baseTexture.source,
|
||||
frame.x,
|
||||
frame.y,
|
||||
|
||||
@@ -33,7 +33,6 @@ PIXI.PixiShader = function(gl)
|
||||
'}'
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @property {number} textureCount - A local texture counter for multi-texture shaders.
|
||||
*/
|
||||
@@ -51,7 +50,6 @@ PIXI.PixiShader = function(gl)
|
||||
*/
|
||||
PIXI.PixiShader.prototype.init = function()
|
||||
{
|
||||
|
||||
var gl = this.gl;
|
||||
|
||||
var program = PIXI.compileProgram(gl, this.vertexSrc || PIXI.PixiShader.defaultVertexSrc, this.fragmentSrc);
|
||||
@@ -305,7 +303,6 @@ PIXI.PixiShader.prototype.syncUniforms = function()
|
||||
/**
|
||||
* Destroys the shader
|
||||
* @method destroy
|
||||
*
|
||||
*/
|
||||
PIXI.PixiShader.prototype.destroy = function()
|
||||
{
|
||||
@@ -317,7 +314,7 @@ PIXI.PixiShader.prototype.destroy = function()
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* The Default Vertex shader source
|
||||
* @property defaultVertexSrc
|
||||
* @type String
|
||||
*/
|
||||
@@ -341,7 +338,3 @@ PIXI.PixiShader.defaultVertexSrc = [
|
||||
' vColor = vec4(color * aColor.x, aColor.x);',
|
||||
'}'
|
||||
];
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -122,6 +122,7 @@ PIXI.WebGLFastSpriteBatch.prototype.render = function(spriteBatch)
|
||||
PIXI.WebGLFastSpriteBatch.prototype.renderSprite = function(sprite)
|
||||
{
|
||||
//sprite = children[i];
|
||||
if(!sprite.visible)return;
|
||||
|
||||
// TODO trim??
|
||||
if(sprite.texture.baseTexture !== this.currentBaseTexture)
|
||||
|
||||
Reference in New Issue
Block a user