Merge pull request #1 from photonstorm/dev

update to official
This commit is contained in:
cuixiping 2015-04-04 16:09:13 +08:00
commit a4c4c643f4
8 changed files with 65 additions and 25 deletions

View file

@ -97,6 +97,10 @@ or the minified version:
`<script src="//cdn.jsdelivr.net/phaser/2.3.0/phaser.min.js"></script>`
[cdnjs.com](https://cdnjs.com/libraries/phaser) also offers a free CDN service. They have all versions of Phaser and even the custom builds:
`<script src="https://cdnjs.cloudflare.com/ajax/libs/phaser/2.3.0/phaser.js"></script>`
### Phaser Sandbox
If you'd like to try coding in Phaser right now, with nothing more than your web browser then you can head over to the [Phaser Sandbox](http://phaser.io/sandbox). You'll find Quick Start templates and a user-friendly editor filled with handy code-completion features.
@ -244,6 +248,7 @@ Version 2.3.1 - "Katar" - in dev
### Updates
* TypeScript definitions fixes and updates (thanks @clark-stevenson @isuda)
* Added missing `resumed` method to Phaser.State class template.
### Bug Fixes
@ -251,6 +256,8 @@ Version 2.3.1 - "Katar" - in dev
* The LoadTexture component has had a redundant `dirty` call removed from it.
* TileSprites were missing a `physicsType` property, causing them to not collide with anything (thanks @numbofathma #1702)
* Sprite was missing the Health and InCamera components.
* A Tween could be incorrectly set to never end if it was given a duration of zero (thanks @hardalias #1710)
* Added guards around `context.getImageData` calls in BitmapData, Text and Canvas Tinting classes to avoid crashing restricted browsers like Epic Browser. Please understand that several Phaser features won't work correctly with this browser (thanks @Erik3000 #1714)
For changes in previous releases please see the extensive [Version History](https://github.com/photonstorm/phaser/blob/master/CHANGELOG.md).

View file

@ -64,9 +64,16 @@ Phaser.BitmapData = function (game, key, width, height) {
this.imageData = this.context.getImageData(0, 0, width, height);
/**
* @property {Uint8ClampedArray} data - A Uint8ClampedArray view into BitmapData.buffer.
* A Uint8ClampedArray view into BitmapData.buffer.
* Note that this is unavailable in some browsers (such as Epic Browser due to its security restrictions)
* @property {Uint8ClampedArray} data
*/
this.data = this.imageData.data;
this.data = null;
if (this.imageData)
{
this.data = this.imageData.data;
}
/**
* @property {Uint32Array} pixels - An Uint32Array view into BitmapData.buffer.
@ -76,21 +83,24 @@ Phaser.BitmapData = function (game, key, width, height) {
/**
* @property {ArrayBuffer} buffer - An ArrayBuffer the same size as the context ImageData.
*/
if (this.imageData.data.buffer)
if (this.data)
{
this.buffer = this.imageData.data.buffer;
this.pixels = new Uint32Array(this.buffer);
}
else
{
if (window['ArrayBuffer'])
if (this.imageData.data.buffer)
{
this.buffer = new ArrayBuffer(this.imageData.data.length);
this.buffer = this.imageData.data.buffer;
this.pixels = new Uint32Array(this.buffer);
}
else
{
this.pixels = this.imageData.data;
if (window['ArrayBuffer'])
{
this.buffer = new ArrayBuffer(this.imageData.data.length);
this.pixels = new Uint32Array(this.buffer);
}
else
{
this.pixels = this.imageData.data;
}
}
}

View file

@ -237,6 +237,11 @@ PIXI.CanvasTinter.checkInverseAlpha = function()
// Get the color values
var s1 = canvas.context.getImageData(0, 0, 1, 1);
if (s1 === null)
{
return false;
}
// Plot them to x2
canvas.context.putImageData(s1, 1, 0);

View file

@ -353,7 +353,7 @@ PIXI.Text.prototype.determineFontProperties = function(fontStyle)
{
var properties = PIXI.Text.fontPropertiesCache[fontStyle];
if(!properties)
if (!properties)
{
properties = {};
@ -380,6 +380,17 @@ PIXI.Text.prototype.determineFontProperties = function(fontStyle)
context.fillStyle = '#000';
context.fillText('|MÉq', 0, baseline);
if (!context.getImageData(0, 0, width, height))
{
properties.ascent = baseline;
properties.descent = baseline + 6;
properties.fontSize = properties.ascent + properties.descent;
PIXI.Text.fontPropertiesCache[fontStyle] = properties;
return properties;
}
var imagedata = context.getImageData(0, 0, width, height).data;
var pixels = imagedata.length;
var line = width * 4;
@ -390,17 +401,18 @@ PIXI.Text.prototype.determineFontProperties = function(fontStyle)
var stop = false;
// ascent. scan from top to bottom until we find a non red pixel
for(i = 0; i < baseline; i++)
for (i = 0; i < baseline; i++)
{
for(j = 0; j < line; j += 4)
for (j = 0; j < line; j += 4)
{
if(imagedata[idx + j] !== 255)
if (imagedata[idx + j] !== 255)
{
stop = true;
break;
}
}
if(!stop)
if (!stop)
{
idx += line;
}
@ -416,17 +428,18 @@ PIXI.Text.prototype.determineFontProperties = function(fontStyle)
stop = false;
// descent. scan from bottom to top until we find a non red pixel
for(i = height; i > baseline; i--)
for (i = height; i > baseline; i--)
{
for(j = 0; j < line; j += 4)
for (j = 0; j < line; j += 4)
{
if(imagedata[idx + j] !== 255)
if (imagedata[idx + j] !== 255)
{
stop = true;
break;
}
}
if(!stop)
if (!stop)
{
idx -= line;
}

View file

@ -49,6 +49,11 @@ PIXI.canUseNewCanvasBlendModes = function()
context.drawImage(magenta, 0, 0);
context.drawImage(yellow, 2, 0);
if (!context.getImageData(2,0,1,1))
{
return false;
}
var data = context.getImageData(2,0,1,1).data;
return (data[0] === 255 && data[1] === 0 && data[2] === 0);

View file

@ -183,7 +183,7 @@ Phaser.Tween.prototype = {
*/
to: function (properties, duration, ease, autoStart, delay, repeat, yoyo) {
if (typeof duration === 'undefined') { duration = 1000; }
if (typeof duration === 'undefined' || duration <= 0) { duration = 1000; }
if (typeof ease === 'undefined') { ease = Phaser.Easing.Default; }
if (typeof autoStart === 'undefined') { autoStart = false; }
if (typeof delay === 'undefined') { delay = 0; }

View file

@ -7142,7 +7142,7 @@ declare module Phaser {
* @param child The child to bring to the top of this group.
* @return The child that was moved.
*/
bringToTop(): PIXI.DisplayObject;
bringToTop(child: any): any;
/**
* Calls a function, specified by name, on all on children.
@ -7454,7 +7454,7 @@ declare module Phaser {
* @param child The child to move down in the group.
* @return The child that was moved.
*/
moveDown(): PIXI.DisplayObject;
moveDown(child: any): any;
/**
* Moves the given child up one place in this group unless it's already at the top.

View file

@ -1451,7 +1451,7 @@ declare module Phaser {
addAll(property: string, amount: number, checkAlive: boolean, checkVisible: boolean): void;
addAt(child: any, index: number, silent?: boolean): any;
addMultiple(children: any[], silent?: boolean): any[];
bringToTop(): PIXI.DisplayObject;
bringToTop(child: any): any;
callAll(method: string, context: any, ...parameters: any[]): void;
callAllExists(callback: Function, existsValue: boolean, ...parameters: any[]): void;
callbackFromArray(child: any, callback: Function, length: number): void;
@ -1479,7 +1479,7 @@ declare module Phaser {
getTop(): any;
hasProperty(child: any, key: string[]): boolean;
iterate(key: string, value: any, returnType: number, callback?: Function, callbackContext?: any, ...args: any[]): any;
moveDown(): PIXI.DisplayObject;
moveDown(child: any): any;
moveUp(child: any): any;
multiplyAll(property: string, amount: number, checkAlive: boolean, checkVisible: boolean): void;
next(): void;