Phaser 2.2.2 Release files.

This commit is contained in:
photonstorm 2015-01-06 06:58:36 +00:00
parent 1b34216f6e
commit 6c7c0cb1b6
15 changed files with 2669 additions and 1226 deletions

View file

@ -13643,10 +13643,22 @@ Phaser.Physics.P2 = function (game, config) {
*/
this.game = game;
if (typeof config === 'undefined' || !config.hasOwnProperty('gravity') || !config.hasOwnProperty('broadphase'))
if (typeof config === 'undefined')
{
config = { gravity: [0, 0], broadphase: new p2.SAPBroadphase() };
}
else
{
if (!config.hasOwnProperty('gravity'))
{
config.gravity = [0, 0];
}
if (!config.hasOwnProperty('broadphase'))
{
config.broadphase = new p2.SAPBroadphase();
}
}
/**
* @property {object} config - The p2 World configuration object.
@ -13974,18 +13986,18 @@ Phaser.Physics.P2.prototype = {
*/
postBroadphaseHandler: function (event) {
var i = event.pairs.length;
if (this.postBroadphaseCallback && i > 0)
if (!this.postBroadphaseCallback || event.pairs.length === 0)
{
while (i -= 2)
return;
}
for (var i = event.pairs.length - 2; i >= 0; i -= 2)
{
if (event.pairs[i].parent && event.pairs[i+1].parent && !this.postBroadphaseCallback.call(this.callbackContext, event.pairs[i].parent, event.pairs[i+1].parent))
{
event.pairs.splice(i, 2);
}
}
}
},

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

View file

@ -47,7 +47,7 @@ PIXI.CANVAS_RENDERER = 1;
PIXI.VERSION = "v2.2.0";
/**
* Various blend modes supported by pixi.
* Various blend modes supported by pixi. IMPORTANT - The WebGL renderer only supports the NORMAL, ADD, MULTIPLY and SCREEN blend modes.
* @property {Object} blendModes
* @property {Number} blendModes.NORMAL
* @property {Number} blendModes.ADD
@ -251,7 +251,21 @@ PIXI.Polygon = function(points)
}
this.closed = true;
/**
* An array of the points of this polygon
* @property points
* @type Array(Point)|Array(Number)
*
*/
this.points = points;
/**
* The type of the object, should be one of the Graphics type consts, PIXI.Graphics.POLY in this case
* @property type
* @type Number
* @default 0
*/
};
/**
@ -609,6 +623,13 @@ PIXI.Rectangle = function(x, y, width, height)
* @default 0
*/
this.height = height || 0;
/**
* The type of the object, should be one of the Graphics type consts, PIXI.Graphics.RECT in this case
* @property type
* @type Number
* @default 0
*/
};
/**
@ -666,7 +687,7 @@ PIXI.EmptyRectangle = new PIXI.Rectangle(0,0,0,0);
* @param y {Number} The Y coordinate of the upper-left corner of the rounded rectangle
* @param width {Number} The overall width of this rounded rectangle
* @param height {Number} The overall height of this rounded rectangle
* @param radius {Number} The overall radius of this corners of this rounded rectangle
* @param radius {Number} Controls the radius of the rounded corners
*/
PIXI.RoundedRectangle = function(x, y, width, height, radius)
{
@ -704,6 +725,13 @@ PIXI.RoundedRectangle = function(x, y, width, height, radius)
* @default 20
*/
this.radius = radius || 20;
/**
* The type of the object, should be one of the Graphics type consts, PIXI.Graphics.RRECT in this case
* @property type
* @type Number
* @default 0
*/
};
/**
@ -2938,6 +2966,10 @@ PIXI.Text.prototype.updateText = function()
if(navigator.isCocoonJS) this.context.clearRect(0,0,this.canvas.width,this.canvas.height);
// used for debugging..
//this.context.fillStyle ="#FF0000"
//this.context.fillRect(0, 0, this.canvas.width,this.canvas.height);
this.context.font = this.style.font;
this.context.strokeStyle = this.style.stroke;
this.context.lineWidth = this.style.strokeThickness;
@ -3166,6 +3198,8 @@ PIXI.Text.prototype.determineFontProperties = function(fontStyle)
}
properties.descent = i - baseline;
//TODO might need a tweak. kind of a temp fix!
properties.descent += 6;
properties.fontSize = properties.ascent + properties.descent;
PIXI.Text.fontPropertiesCache[fontStyle] = properties;
@ -3818,9 +3852,18 @@ PIXI.getNextPowerOfTwo = function(number)
return result;
}
};
/**
* checks if the given width and height make a power of two texture
* @method isPowerOfTwo
* @param width {Number}
* @param height {Number}
* @return {Boolean}
*/
PIXI.isPowerOfTwo = function(width, height)
{
return (width > 0 && (width & (width - 1)) === 0 && height > 0 && (height & (height - 1)) === 0);
};
/**
@ -5092,13 +5135,14 @@ PIXI.PrimitiveShader = function(gl)
'uniform vec2 projectionVector;',
'uniform vec2 offsetVector;',
'uniform float alpha;',
'uniform float flipY;',
'uniform vec3 tint;',
'varying vec4 vColor;',
'void main(void) {',
' vec3 v = translationMatrix * vec3(aVertexPosition , 1.0);',
' v -= offsetVector.xyx;',
' gl_Position = vec4( v.x / projectionVector.x -1.0, v.y / -projectionVector.y + 1.0 , 0.0, 1.0);',
' gl_Position = vec4( v.x / projectionVector.x -1.0, (v.y / projectionVector.y * -flipY) + flipY , 0.0, 1.0);',
' vColor = aColor * vec4(tint * alpha, alpha);',
'}'
];
@ -5124,6 +5168,7 @@ PIXI.PrimitiveShader.prototype.init = function()
this.projectionVector = gl.getUniformLocation(program, 'projectionVector');
this.offsetVector = gl.getUniformLocation(program, 'offsetVector');
this.tintColor = gl.getUniformLocation(program, 'tint');
this.flipY = gl.getUniformLocation(program, 'flipY');
// get and store the attributes
this.aVertexPosition = gl.getAttribLocation(program, 'aVertexPosition');
@ -5213,13 +5258,13 @@ PIXI.ComplexPrimitiveShader = function(gl)
'uniform vec3 tint;',
'uniform float alpha;',
'uniform vec3 color;',
'uniform float flipY;',
'varying vec4 vColor;',
'void main(void) {',
' vec3 v = translationMatrix * vec3(aVertexPosition , 1.0);',
' v -= offsetVector.xyx;',
' gl_Position = vec4( v.x / projectionVector.x -1.0, v.y / -projectionVector.y + 1.0 , 0.0, 1.0);',
' gl_Position = vec4( v.x / projectionVector.x -1.0, (v.y / projectionVector.y * -flipY) + flipY , 0.0, 1.0);',
' vColor = vec4(color * alpha * tint, alpha);',//" * vec4(tint * alpha, alpha);',
'}'
];
@ -5246,6 +5291,7 @@ PIXI.ComplexPrimitiveShader.prototype.init = function()
this.offsetVector = gl.getUniformLocation(program, 'offsetVector');
this.tintColor = gl.getUniformLocation(program, 'tint');
this.color = gl.getUniformLocation(program, 'color');
this.flipY = gl.getUniformLocation(program, 'flipY');
// get and store the attributes
this.aVertexPosition = gl.getAttribLocation(program, 'aVertexPosition');
@ -5336,6 +5382,8 @@ PIXI.WebGLGraphics.renderGraphics = function(graphics, renderSession)//projectio
shader = renderSession.shaderManager.primitiveShader;
gl.uniformMatrix3fv(shader.translationMatrix, false, graphics.worldTransform.toArray(true));
gl.uniform1f(shader.flipY, 1);
gl.uniform2f(shader.projectionVector, projection.x, -projection.y);
gl.uniform2f(shader.offsetVector, -offset.x, -offset.y);
@ -5624,6 +5672,8 @@ PIXI.WebGLGraphics.buildRoundedRectangle = function(graphicsData, webGLData)
var triangles = PIXI.PolyK.Triangulate(recPoints);
//
var i = 0;
for (i = 0; i < triangles.length; i+=3)
{
@ -5634,6 +5684,7 @@ PIXI.WebGLGraphics.buildRoundedRectangle = function(graphicsData, webGLData)
indices.push(triangles[i+2] + vecPos);
}
for (i = 0; i < recPoints.length; i++)
{
verts.push(recPoints[i], recPoints[++i], r, g, b, alpha);
@ -6523,6 +6574,9 @@ PIXI.WebGLRenderer.prototype.renderDisplayObject = function(displayObject, proje
// reset the render session data..
this.renderSession.drawCount = 0;
// make sure to flip the Y if using a render texture..
this.renderSession.flipY = buffer ? -1 : 1;
// set the default projection
this.renderSession.projection = projection;
@ -6991,6 +7045,8 @@ PIXI.WebGLStencilManager.prototype.bindGraphics = function(graphics, webGLData,
renderSession.shaderManager.setShader( shader );
gl.uniform1f(shader.flipY, renderSession.flipY);
gl.uniformMatrix3fv(shader.translationMatrix, false, graphics.worldTransform.toArray(true));
gl.uniform2f(shader.projectionVector, projection.x, -projection.y);
@ -7018,6 +7074,7 @@ PIXI.WebGLStencilManager.prototype.bindGraphics = function(graphics, webGLData,
gl.uniformMatrix3fv(shader.translationMatrix, false, graphics.worldTransform.toArray(true));
gl.uniform1f(shader.flipY, renderSession.flipY);
gl.uniform2f(shader.projectionVector, projection.x, -projection.y);
gl.uniform2f(shader.offsetVector, -offset.x, -offset.y);
@ -8159,7 +8216,7 @@ PIXI.WebGLFastSpriteBatch.prototype.renderSprite = function(sprite)
if(!sprite.texture._uvs)return;
}
var uvs, verticies = this.vertices, width, height, w0, w1, h0, h1, index;
var uvs, vertices = this.vertices, width, height, w0, w1, h0, h1, index;
uvs = sprite.texture._uvs;
@ -8189,89 +8246,89 @@ PIXI.WebGLFastSpriteBatch.prototype.renderSprite = function(sprite)
index = this.currentBatchSize * 4 * this.vertSize;
// xy
verticies[index++] = w1;
verticies[index++] = h1;
vertices[index++] = w1;
vertices[index++] = h1;
verticies[index++] = sprite.position.x;
verticies[index++] = sprite.position.y;
vertices[index++] = sprite.position.x;
vertices[index++] = sprite.position.y;
//scale
verticies[index++] = sprite.scale.x;
verticies[index++] = sprite.scale.y;
vertices[index++] = sprite.scale.x;
vertices[index++] = sprite.scale.y;
//rotation
verticies[index++] = sprite.rotation;
vertices[index++] = sprite.rotation;
// uv
verticies[index++] = uvs.x0;
verticies[index++] = uvs.y1;
vertices[index++] = uvs.x0;
vertices[index++] = uvs.y1;
// color
verticies[index++] = sprite.alpha;
vertices[index++] = sprite.alpha;
// xy
verticies[index++] = w0;
verticies[index++] = h1;
vertices[index++] = w0;
vertices[index++] = h1;
verticies[index++] = sprite.position.x;
verticies[index++] = sprite.position.y;
vertices[index++] = sprite.position.x;
vertices[index++] = sprite.position.y;
//scale
verticies[index++] = sprite.scale.x;
verticies[index++] = sprite.scale.y;
vertices[index++] = sprite.scale.x;
vertices[index++] = sprite.scale.y;
//rotation
verticies[index++] = sprite.rotation;
vertices[index++] = sprite.rotation;
// uv
verticies[index++] = uvs.x1;
verticies[index++] = uvs.y1;
vertices[index++] = uvs.x1;
vertices[index++] = uvs.y1;
// color
verticies[index++] = sprite.alpha;
vertices[index++] = sprite.alpha;
// xy
verticies[index++] = w0;
verticies[index++] = h0;
vertices[index++] = w0;
vertices[index++] = h0;
verticies[index++] = sprite.position.x;
verticies[index++] = sprite.position.y;
vertices[index++] = sprite.position.x;
vertices[index++] = sprite.position.y;
//scale
verticies[index++] = sprite.scale.x;
verticies[index++] = sprite.scale.y;
vertices[index++] = sprite.scale.x;
vertices[index++] = sprite.scale.y;
//rotation
verticies[index++] = sprite.rotation;
vertices[index++] = sprite.rotation;
// uv
verticies[index++] = uvs.x2;
verticies[index++] = uvs.y2;
vertices[index++] = uvs.x2;
vertices[index++] = uvs.y2;
// color
verticies[index++] = sprite.alpha;
vertices[index++] = sprite.alpha;
// xy
verticies[index++] = w1;
verticies[index++] = h0;
vertices[index++] = w1;
vertices[index++] = h0;
verticies[index++] = sprite.position.x;
verticies[index++] = sprite.position.y;
vertices[index++] = sprite.position.x;
vertices[index++] = sprite.position.y;
//scale
verticies[index++] = sprite.scale.x;
verticies[index++] = sprite.scale.y;
vertices[index++] = sprite.scale.x;
vertices[index++] = sprite.scale.y;
//rotation
verticies[index++] = sprite.rotation;
vertices[index++] = sprite.rotation;
// uv
verticies[index++] = uvs.x3;
verticies[index++] = uvs.y3;
vertices[index++] = uvs.x3;
vertices[index++] = uvs.y3;
// color
verticies[index++] = sprite.alpha;
vertices[index++] = sprite.alpha;
// increment the batchs
this.currentBatchSize++;
@ -10871,10 +10928,8 @@ PIXI.TilingSprite.prototype._renderWebGL = function(renderSession)
if (this.tilingTexture && this.tilingTexture.needsUpdate)
{
//TODO - tweaking
PIXI.updateWebGLTexture(this.tilingTexture.baseTexture, renderSession.gl);
renderSession.renderer.updateTexture(this.tilingTexture.baseTexture);
this.tilingTexture.needsUpdate = false;
// this.tilingTexture._uvs = null;
}
}
else

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

44
build/phaser.min.js vendored

File diff suppressed because one or more lines are too long