Skip to content

Commit b6c2b4e

Browse files
committed
1 parent 29040b3 commit b6c2b4e

15 files changed

Lines changed: 165 additions & 57 deletions

File tree

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ Version 2.0.4 - "Mos Shirare" - in development
6060

6161
### Updates
6262

63+
* Updated to [Pixi.js 1.5.3](https://github.com/GoodBoyDigital/pixi.js/releases/tag/v1.5.3)
6364
* TypeScript definitions fixes and updates (thanks @clark-stevenson @metrofun)
6465
* Timer has removed all use of local temporary vars in the core update loop.
6566
* The Input.reset `hard` reset parameter is now passed down to the Keyboard and Key reset methods.
@@ -97,7 +98,7 @@ Version 2.0.4 - "Mos Shirare" - in development
9798
* BitmapData.processPixelRGB lets you perform a custom callback on every pixel in the BitmapData.
9899
* P2.World now has its own pause and resume methods, so you can pause the physics simulation independent of your game (thanks @georgiee)
99100
* Phaser.ArrayList is a new iterative object, similar in principal to a linked list but operating on a single array without modifying the object structure.
100-
101+
* Add scaleMode params to FilterTexture and RenderTexture (pixi.js update by @giraluna)
101102

102103

103104
### Bug Fixes
@@ -116,6 +117,8 @@ Version 2.0.4 - "Mos Shirare" - in development
116117
* Point.distance used an incorrect Math call if you wanted a rounded distance value (thanks @OpherV, fix #745)
117118
* P2.Body.loadPolygon has been updated to correct center of mass issues (thanks @georgiee, fix #749)
118119
* Game checks if window.console exists before using it (should fix IE9 issues when dev tools are closed), however it is still used deeper in Pixi.
120+
* Masks now work when used in RenderTextures / CacheAsBitmap and Filters (pixi.js update)
121+
* Fixed bug where stroked text sometimes got clipped (pixi.js update)
119122

120123

121124
### ToDo

src/core/ArrayList.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66

77
/**
8-
* A basic stack data structure. Allows items to add themselves to and remove themselves from the stack. Items can only exist once in the stack.
8+
* A set data structure. Allows items to add themselves to and remove themselves from the set. Items can only exist once in the set.
99
*
1010
* @class Phaser.ArrayList
1111
* @constructor

src/pixi/core/Circle.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
*
88
* @class Circle
99
* @constructor
10-
* @param x {Number} The X coordinate of the upper-left corner of the framing rectangle of this circle
11-
* @param y {Number} The Y coordinate of the upper-left corner of the framing rectangle of this circle
10+
* @param x {Number} The X coordinate of the center of this circle
11+
* @param y {Number} The Y coordinate of the center of this circle
1212
* @param radius {Number} The radius of the circle
1313
*/
1414
PIXI.Circle = function(x, y, radius)

src/pixi/display/DisplayObject.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
*/
44

55
/**
6-
* The base class for all objects that are rendered on the screen.
6+
* The base class for all objects that are rendered on the screen.
7+
* This is an abstract class and should not be used on its own rather it should be extended.
78
*
89
* @class DisplayObject
910
* @constructor
@@ -498,7 +499,7 @@ PIXI.DisplayObject.prototype.generateTexture = function(renderer)
498499
var bounds = this.getLocalBounds();
499500

500501
var renderTexture = new PIXI.RenderTexture(bounds.width | 0, bounds.height | 0, renderer);
501-
renderTexture.render(this);
502+
renderTexture.render(this, new PIXI.Point(-bounds.x, -bounds.y) );
502503

503504
return renderTexture;
504505
};
@@ -542,7 +543,11 @@ PIXI.DisplayObject.prototype._generateCachedSprite = function()//renderSession)
542543
this._filters = null;
543544

544545
this._cachedSprite.filters = tempFilters;
545-
this._cachedSprite.texture.render(this);
546+
this._cachedSprite.texture.render(this, new PIXI.Point(-bounds.x, -bounds.y) );
547+
548+
this._cachedSprite.anchor.x = -( bounds.x / bounds.width );
549+
this._cachedSprite.anchor.y = -( bounds.y / bounds.height );
550+
546551

547552
this._filters = tempFilters;
548553

src/pixi/display/MovieClip.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,3 +164,41 @@ PIXI.MovieClip.prototype.updateTransform = function()
164164
}
165165
}
166166
};
167+
168+
/**
169+
* A short hand way of creating a movieclip from an array of frame ids
170+
*
171+
* @static
172+
* @method fromFrames
173+
* @param frames {Array} the array of frames ids the movieclip will use as its texture frames
174+
*/
175+
PIXI.MovieClip.prototype.fromFrames = function(frames)
176+
{
177+
var textures = [];
178+
179+
for (var i = 0; i < frames.length; i++)
180+
{
181+
textures.push(new PIXI.Texture.fromFrame(frames[i]));
182+
}
183+
184+
return new PIXI.MovieClip(textures);
185+
};
186+
187+
/**
188+
* A short hand way of creating a movieclip from an array of image ids
189+
*
190+
* @static
191+
* @method fromFrames
192+
* @param frames {Array} the array of image ids the movieclip will use as its texture frames
193+
*/
194+
PIXI.MovieClip.prototype.fromImages = function(images)
195+
{
196+
var textures = [];
197+
198+
for (var i = 0; i < images.length; i++)
199+
{
200+
textures.push(new PIXI.Texture.fromImage(images[i]));
201+
}
202+
203+
return new PIXI.MovieClip(textures);
204+
};

src/pixi/extras/Strip.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
*/
1515
PIXI.Strip = function(texture, width, height)
1616
{
17-
PIXI.DisplayObjectContainer.call( this );
17+
PIXI.Sprite.call( this, texture );
18+
this.width =width;
19+
this.height = height;
1820
this.texture = texture;
1921
this.blendMode = PIXI.blendModes.NORMAL;
2022

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

60-
this.width = width;
61-
this.height = height;
62+
// this.width = width;
63+
// this.height = height;
6264

6365
// load the texture!
66+
6467
if(texture.baseTexture.hasLoaded)
6568
{
6669
this.width = this.texture.frame.width;
@@ -77,7 +80,7 @@ PIXI.Strip = function(texture, width, height)
7780
};
7881

7982
// constructor
80-
PIXI.Strip.prototype = Object.create(PIXI.DisplayObjectContainer.prototype);
83+
PIXI.Strip.prototype = Object.create(PIXI.Sprite.prototype);
8184
PIXI.Strip.prototype.constructor = PIXI.Strip;
8285

8386
/*
@@ -87,6 +90,8 @@ PIXI.Strip.prototype.constructor = PIXI.Strip;
8790
* @param texture {Texture} the texture that will be used
8891
* @private
8992
*/
93+
94+
/*
9095
PIXI.Strip.prototype.setTexture = function(texture)
9196
{
9297
//TODO SET THE TEXTURES
@@ -98,6 +103,7 @@ PIXI.Strip.prototype.setTexture = function(texture)
98103
this.height = texture.frame.height;
99104
this.updateFrame = true;
100105
};
106+
*/
101107

102108
/**
103109
* When the texture is updated, this event will fire to update the scale and frame
@@ -106,6 +112,7 @@ PIXI.Strip.prototype.setTexture = function(texture)
106112
* @param event
107113
* @private
108114
*/
115+
109116
PIXI.Strip.prototype.onTextureUpdate = function()
110117
{
111118
this.updateFrame = true;

src/pixi/loaders/JsonLoader.js

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,27 @@ PIXI.JsonLoader.prototype.constructor = PIXI.JsonLoader;
6262
*/
6363
PIXI.JsonLoader.prototype.load = function () {
6464

65+
var scope = this;
6566

6667
if(window.XDomainRequest)
6768
{
6869
this.ajaxRequest = new window.XDomainRequest();
70+
71+
// XDomainRequest has a few querks. Occasionally it will abort requests
72+
// A way to avoid this is to make sure ALL callbacks are set even if not used
73+
// More info here: http://stackoverflow.com/questions/15786966/xdomainrequest-aborts-post-on-ie-9
74+
this.ajaxRequest.timeout = 3000;
75+
76+
this.ajaxRequest.onerror = function () {
77+
scope.onError();
78+
};
79+
80+
this.ajaxRequest.ontimeout = function () {
81+
scope.onError();
82+
};
83+
84+
this.ajaxRequest.onprogress = function() {};
85+
6986
}
7087
else if (window.XMLHttpRequest)
7188
{
@@ -78,22 +95,13 @@ PIXI.JsonLoader.prototype.load = function () {
7895

7996

8097

98+
this.ajaxRequest.onload = function(){
8199

82-
// this.ajaxRequest = new PIXI.AjaxRequest(this.crossorigin);
83-
var scope = this;
84-
85-
86-
87-
88-
this.ajaxRequest.onload = function () {
89100
scope.onJSONLoaded();
90101
};
91102

92-
// this.ajaxRequest.open('GET', this.url, true);
93-
// if (this.ajaxRequest.overrideMimeType) this.ajaxRequest.overrideMimeType('application/json');
94-
// this.ajaxRequest.send(null);
103+
this.ajaxRequest.open('GET',this.url,true);
95104

96-
this.ajaxRequest.open('GET',this.url,false);
97105
this.ajaxRequest.send();
98106
};
99107

@@ -104,8 +112,13 @@ PIXI.JsonLoader.prototype.load = function () {
104112
* @private
105113
*/
106114
PIXI.JsonLoader.prototype.onJSONLoaded = function () {
107-
// if (this.ajaxRequest.readyState === 4) {
108-
// if (this.ajaxRequest.status === 200 || window.location.protocol.indexOf('http') === -1) {
115+
116+
if(!this.ajaxRequest.responseText )
117+
{
118+
this.onError();
119+
return;
120+
}
121+
109122
this.json = JSON.parse(this.ajaxRequest.responseText);
110123

111124
if(this.json.frames)
@@ -159,12 +172,6 @@ PIXI.JsonLoader.prototype.onJSONLoaded = function () {
159172
{
160173
this.onLoaded();
161174
}
162-
// }
163-
// else
164-
//{
165-
// this.onError();
166-
// / }
167-
// }
168175
};
169176

170177
/**
@@ -188,6 +195,7 @@ PIXI.JsonLoader.prototype.onLoaded = function () {
188195
* @private
189196
*/
190197
PIXI.JsonLoader.prototype.onError = function () {
198+
191199
this.dispatchEvent({
192200
type: 'error',
193201
content: this

src/pixi/primitives/Graphics.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ PIXI.Graphics = function()
107107
/**
108108
* the bounds' padding used for bounds calculation
109109
*
110-
* @property bounds
110+
* @property boundsPadding
111111
* @type Number
112112
*/
113113
this.boundsPadding = 10;
@@ -488,28 +488,24 @@ PIXI.Graphics.prototype.getBounds = function( matrix )
488488
var x4 = a * w1 + c * h0 + tx;
489489
var y4 = d * h0 + b * w1 + ty;
490490

491-
var maxX = -Infinity;
492-
var maxY = -Infinity;
491+
var maxX = x1;
492+
var maxY = y1;
493493

494-
var minX = Infinity;
495-
var minY = Infinity;
494+
var minX = x1;
495+
var minY = y1;
496496

497-
minX = x1 < minX ? x1 : minX;
498497
minX = x2 < minX ? x2 : minX;
499498
minX = x3 < minX ? x3 : minX;
500499
minX = x4 < minX ? x4 : minX;
501500

502-
minY = y1 < minY ? y1 : minY;
503501
minY = y2 < minY ? y2 : minY;
504502
minY = y3 < minY ? y3 : minY;
505503
minY = y4 < minY ? y4 : minY;
506504

507-
maxX = x1 > maxX ? x1 : maxX;
508505
maxX = x2 > maxX ? x2 : maxX;
509506
maxX = x3 > maxX ? x3 : maxX;
510507
maxX = x4 > maxX ? x4 : maxX;
511508

512-
maxY = y1 > maxY ? y1 : maxY;
513509
maxY = y2 > maxY ? y2 : maxY;
514510
maxY = y3 > maxY ? y3 : maxY;
515511
maxY = y4 > maxY ? y4 : maxY;

src/pixi/renderers/webgl/utils/FilterTexture.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88
* @param gl {WebGLContext} the current WebGL drawing context
99
* @param width {Number} the horizontal range of the filter
1010
* @param height {Number} the vertical range of the filter
11+
* @param scaleMode {Number} Should be one of the PIXI.scaleMode consts
1112
* @private
1213
*/
13-
PIXI.FilterTexture = function(gl, width, height)
14+
PIXI.FilterTexture = function(gl, width, height, scaleMode)
1415
{
1516
/**
1617
* @property gl
@@ -22,16 +23,23 @@ PIXI.FilterTexture = function(gl, width, height)
2223
this.frameBuffer = gl.createFramebuffer();
2324
this.texture = gl.createTexture();
2425

26+
scaleMode = scaleMode || PIXI.scaleModes.DEFAULT;
27+
2528
gl.bindTexture(gl.TEXTURE_2D, this.texture);
26-
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
27-
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
29+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, scaleMode === PIXI.scaleModes.LINEAR ? gl.LINEAR : gl.NEAREST);
30+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, scaleMode === PIXI.scaleModes.LINEAR ? gl.LINEAR : gl.NEAREST);
2831
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
2932
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
3033
gl.bindFramebuffer(gl.FRAMEBUFFER, this.framebuffer );
3134

3235
gl.bindFramebuffer(gl.FRAMEBUFFER, this.frameBuffer );
3336
gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, this.texture, 0);
3437

38+
// required for masking a mask??
39+
this.renderBuffer = gl.createRenderbuffer();
40+
gl.bindRenderbuffer(gl.RENDERBUFFER, this.renderBuffer);
41+
gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.RENDERBUFFER, this.renderBuffer);
42+
3543
this.resize(width, height);
3644
};
3745

@@ -67,6 +75,9 @@ PIXI.FilterTexture.prototype.resize = function(width, height)
6775
gl.bindTexture(gl.TEXTURE_2D, this.texture);
6876
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
6977

78+
// update the stencil buffer width and height
79+
gl.bindRenderbuffer(gl.RENDERBUFFER, this.renderBuffer);
80+
gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_STENCIL, width, height);
7081
};
7182

7283
/**

src/pixi/renderers/webgl/utils/WebGLFilterManager.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,11 @@ PIXI.WebGLFilterManager.prototype.pushFilter = function(filterBlock)
9191

9292
var filterArea = filterBlock._filterArea;// filterBlock.target.getBounds();///filterBlock.target.filterArea;
9393

94-
var padidng = filter.padding;
95-
filterArea.x -= padidng;
96-
filterArea.y -= padidng;
97-
filterArea.width += padidng * 2;
98-
filterArea.height += padidng * 2;
94+
var padding = filter.padding;
95+
filterArea.x -= padding;
96+
filterArea.y -= padding;
97+
filterArea.width += padding * 2;
98+
filterArea.height += padding * 2;
9999

100100
// cap filter to screen size..
101101
if(filterArea.x < 0)filterArea.x = 0;

0 commit comments

Comments
 (0)