Skip to content

Commit 181fd1a

Browse files
committed
Merged Pixi 1.5.4 with Phaser - all of the lovely new Pixi features are in, like complex Graphics objects and masking.
1 parent 3d80568 commit 181fd1a

42 files changed

Lines changed: 2640 additions & 359 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ Version 2.0.6 - "Jornhill" - -in development-
5050

5151
### Updates
5252

53+
* Merged Pixi 1.5.4 with Phaser - all of the lovely new Pixi features are in, like complex Graphics objects and masking.
5354
* TypeScript definitions fixes and updates (thanks @clark-stevenson and @Phaiax)
5455
* Documentation fixes (thanks @kay-is #941)
5556
* BitmapData.draw can now also take a Phaser.Sprite, Phaser.Image or BitmapData object as a source type. As a result BitmapData.drawSprite is now depcreated.
@@ -128,6 +129,12 @@ Version 2.0.6 - "Jornhill" - -in development-
128129
* ArcadePhysics.Body.setSize if you set offset x/y values previously and then passed zero values they would be ignored (thanks @casensiom fix #889)
129130
* InputHandler.checkPointerDown checks and docs updated (thanks @lewster32, fix method #936)
130131

132+
### ToDo
133+
134+
When you add an animation it over-rides the default set frame to the first frame of the animation.
135+
136+
137+
131138

132139
### Migration Guide
133140

build/config.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,11 @@
4949
<script src="$path/src/pixi/renderers/webgl/shaders/PixiFastShader.js"></script>
5050
<script src="$path/src/pixi/renderers/webgl/shaders/StripShader.js"></script>
5151
<script src="$path/src/pixi/renderers/webgl/shaders/PrimitiveShader.js"></script>
52+
<script src="$path/src/pixi/renderers/webgl/shaders/ComplexPrimitiveShader.js"></script>
5253
<script src="$path/src/pixi/renderers/webgl/utils/WebGLGraphics.js"></script>
5354
<script src="$path/src/pixi/renderers/webgl/WebGLRenderer.js"></script>
5455
<script src="$path/src/pixi/renderers/webgl/utils/WebGLMaskManager.js"></script>
56+
<script src="$path/src/pixi/renderers/webgl/utils/WebGLStencilManager.js"></script>
5557
<script src="$path/src/pixi/renderers/webgl/utils/WebGLShaderManager.js"></script>
5658
<script src="$path/src/pixi/renderers/webgl/utils/WebGLSpriteBatch.js"></script>
5759
<script src="$path/src/pixi/renderers/webgl/utils/WebGLFastSpriteBatch.js"></script>
@@ -62,6 +64,8 @@
6264
<script src="$path/src/pixi/renderers/canvas/CanvasRenderer.js"></script>
6365
<script src="$path/src/pixi/renderers/canvas/CanvasGraphics.js"></script>
6466
<script src="$path/src/pixi/primitives/Graphics.js"></script>
67+
<script src="$path/src/pixi/extras/Strip.js"></script>
68+
<script src="$path/src/pixi/extras/Rope.js"></script>
6569
<script src="$path/src/pixi/extras/TilingSprite.js"></script>
6670
<script src="$path/src/pixi/textures/BaseTexture.js"></script>
6771
<script src="$path/src/pixi/textures/Texture.js"></script>

src/pixi/InteractionData.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ PIXI.InteractionData = function()
1818
*/
1919
this.global = new PIXI.Point();
2020

21-
// this is here for legacy... but will remove
22-
this.local = new PIXI.Point();
23-
21+
2422
/**
2523
* The target Sprite that was interacted with
2624
*

src/pixi/InteractionManager.js

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -571,14 +571,12 @@ PIXI.InteractionManager.prototype.onTouchMove = function(event)
571571
touchData.global.x = touchEvent.clientX;
572572
touchData.global.y = touchEvent.clientY;
573573
}
574-
}
575574

576-
var length = this.interactiveItems.length;
577-
for (i = 0; i < length; i++)
578-
{
579-
var item = this.interactiveItems[i];
580-
if(item.touchmove)
581-
item.touchmove(touchData);
575+
for (var j = 0; j < this.interactiveItems.length; j++)
576+
{
577+
var item = this.interactiveItems[j];
578+
if(item.touchmove && item.__touchData && item.__touchData[touchEvent.identifier]) item.touchmove(touchData);
579+
}
582580
}
583581
};
584582

@@ -628,7 +626,8 @@ PIXI.InteractionManager.prototype.onTouchStart = function(event)
628626
//call the function!
629627
if(item.touchstart)item.touchstart(touchData);
630628
item.__isDown = true;
631-
item.__touchData = touchData;
629+
item.__touchData = item.__touchData || {};
630+
item.__touchData[touchEvent.identifier] = touchData;
632631

633632
if(!item.interactiveChildren)break;
634633
}
@@ -666,11 +665,11 @@ PIXI.InteractionManager.prototype.onTouchEnd = function(event)
666665
for (var j = 0; j < length; j++)
667666
{
668667
var item = this.interactiveItems[j];
669-
var itemTouchData = item.__touchData; // <-- Here!
670-
item.__hit = this.hitTest(item, touchData);
671668

672-
if(itemTouchData === touchData)
673-
{
669+
if(item.__touchData && item.__touchData[touchEvent.identifier]) {
670+
671+
item.__hit = this.hitTest(item, item.__touchData[touchEvent.identifier]);
672+
674673
// so this one WAS down...
675674
touchData.originalEvent = event || window.event;
676675
// hitTest??
@@ -698,15 +697,8 @@ PIXI.InteractionManager.prototype.onTouchEnd = function(event)
698697
item.__isDown = false;
699698
}
700699

701-
item.__touchData = null;
702-
703-
}
704-
/*
705-
else
706-
{
707-
700+
item.__touchData[touchEvent.identifier] = null;
708701
}
709-
*/
710702
}
711703
// remove the touch..
712704
this.pool.push(touchData);

src/pixi/Outro.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
}
99
exports.PIXI = PIXI;
1010
} else if (typeof define !== 'undefined' && define.amd) {
11-
define('PIXI', (function() { return root.PIXI = PIXI; })() );
11+
define(PIXI);
1212
} else {
1313
root.PIXI = PIXI;
1414
}

src/pixi/Pixi.js

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ PIXI.WEBGL_RENDERER = 0;
1616
PIXI.CANVAS_RENDERER = 1;
1717

1818
// useful for testing against if your lib is using pixi.
19-
PIXI.VERSION = "v1.5.2";
19+
PIXI.VERSION = 'v1.5.4';
2020

2121
// the various blend modes supported by pixi
2222
PIXI.blendModes = {
@@ -46,9 +46,44 @@ PIXI.scaleModes = {
4646
NEAREST:1
4747
};
4848

49+
// used to create uids for various pixi objects..
50+
PIXI._UID = 0;
51+
52+
PIXI.Float32Array = Float32Array || Array;
53+
PIXI.Uint16Array = Uint16Array || Array;
54+
4955
// interaction frequency
5056
PIXI.INTERACTION_FREQUENCY = 30;
5157
PIXI.AUTO_PREVENT_DEFAULT = true;
5258

5359
PIXI.RAD_TO_DEG = 180 / Math.PI;
54-
PIXI.DEG_TO_RAD = Math.PI / 180;
60+
PIXI.DEG_TO_RAD = Math.PI / 180;
61+
62+
PIXI.sayHello = function ()
63+
{
64+
if ( navigator.userAgent.toLowerCase().indexOf('chrome') > -1 )
65+
{
66+
var args = [
67+
'%c %c %c Pixi.js ' + PIXI.VERSION + ' %c %c ' + ' http://pixjs.com %c %c ♥%c♥%c♥ ',
68+
'background: #ed2577',
69+
'background: #ed2577',
70+
'color: #ed2577; background: #0a0c1a;',
71+
'background: #ed2577',
72+
'background: #0a0c1a',
73+
'background: #ed2577',
74+
'color: #ff2424; background: #fff',
75+
'color: #ff2424; background: #fff',
76+
'color: #ff2424; background: #fff'
77+
];
78+
79+
80+
81+
console.log.apply(console, args);
82+
}
83+
else if (window['console'])
84+
{
85+
console.log('Pixi.js ' + PIXI.VERSION + ' - http://pixjs.com');
86+
}
87+
};
88+
89+
PIXI.sayHello();

src/pixi/core/Matrix.js

Lines changed: 44 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,16 @@
22
* @author Mat Groves http://matgroves.com/ @Doormat23
33
*/
44

5-
PIXI.determineMatrixArrayType = function() {
6-
return (typeof Float32Array !== 'undefined') ? Float32Array : Array;
7-
};
8-
9-
/*
10-
* @class Matrix2
11-
* The Matrix2 class will choose the best type of array to use between
12-
* a regular javascript Array and a Float32Array if the latter is available
13-
*
14-
*/
15-
PIXI.Matrix2 = PIXI.determineMatrixArrayType();
16-
17-
/*
18-
* @class Matrix
19-
* The Matrix class is now an object, which makes it a lot faster,
20-
* here is a representation of it :
21-
* | a | b | tx|
22-
* | c | c | ty|
23-
* | 0 | 0 | 1 |
24-
*
25-
*/
5+
/**
6+
* The Matrix class is now an object, which makes it a lot faster,
7+
* here is a representation of it :
8+
* | a | b | tx|
9+
* | c | c | ty|
10+
* | 0 | 0 | 1 |
11+
*
12+
* @class Matrix
13+
* @constructor
14+
*/
2615
PIXI.Matrix = function()
2716
{
2817
this.a = 1;
@@ -54,7 +43,7 @@ PIXI.Matrix.prototype.fromArray = function(array)
5443
*
5544
* @method toArray
5645
* @param transpose {Boolean} Whether we need to transpose the matrix or not
57-
* @return array {Array} the newly created array which contains the matrix
46+
* @return {Array} the newly created array which contains the matrix
5847
*/
5948
PIXI.Matrix.prototype.toArray = function(transpose)
6049
{
@@ -63,30 +52,43 @@ PIXI.Matrix.prototype.toArray = function(transpose)
6352

6453
if(transpose)
6554
{
66-
this.array[0] = this.a;
67-
this.array[1] = this.c;
68-
this.array[2] = 0;
69-
this.array[3] = this.b;
70-
this.array[4] = this.d;
71-
this.array[5] = 0;
72-
this.array[6] = this.tx;
73-
this.array[7] = this.ty;
74-
this.array[8] = 1;
55+
array[0] = this.a;
56+
array[1] = this.c;
57+
array[2] = 0;
58+
array[3] = this.b;
59+
array[4] = this.d;
60+
array[5] = 0;
61+
array[6] = this.tx;
62+
array[7] = this.ty;
63+
array[8] = 1;
7564
}
7665
else
7766
{
78-
this.array[0] = this.a;
79-
this.array[1] = this.b;
80-
this.array[2] = this.tx;
81-
this.array[3] = this.c;
82-
this.array[4] = this.d;
83-
this.array[5] = this.ty;
84-
this.array[6] = 0;
85-
this.array[7] = 0;
86-
this.array[8] = 1;
67+
array[0] = this.a;
68+
array[1] = this.b;
69+
array[2] = this.tx;
70+
array[3] = this.c;
71+
array[4] = this.d;
72+
array[5] = this.ty;
73+
array[6] = 0;
74+
array[7] = 0;
75+
array[8] = 1;
8776
}
8877

89-
return array;//[this.a, this.b, this.tx, this.c, this.d, this.ty, 0, 0, 1];
78+
return array;
9079
};
9180

92-
PIXI.identityMatrix = new PIXI.Matrix();
81+
PIXI.identityMatrix = new PIXI.Matrix();
82+
83+
PIXI.determineMatrixArrayType = function() {
84+
return (typeof Float32Array !== 'undefined') ? Float32Array : Array;
85+
};
86+
87+
/**
88+
* The Matrix2 class will choose the best type of array to use between
89+
* a regular javascript Array and a Float32Array if the latter is available
90+
*
91+
* @class Matrix2
92+
* @constructor
93+
*/
94+
PIXI.Matrix2 = PIXI.determineMatrixArrayType();

src/pixi/core/Point.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,19 @@ PIXI.Point.prototype.clone = function()
3838
return new PIXI.Point(this.x, this.y);
3939
};
4040

41-
// constructor
42-
PIXI.Point.prototype.constructor = PIXI.Point;
43-
41+
/**
42+
* Sets the point to a new x and y position.
43+
* If y is ommited, both x and y will be set to x.
44+
*
45+
* @method set
46+
* @param [x=0] {Number} position of the point on the x axis
47+
* @param [y=0] {Number} position of the point on the y axis
48+
*/
4449
PIXI.Point.prototype.set = function(x, y)
4550
{
4651
this.x = x || 0;
4752
this.y = y || ( (y !== 0) ? this.x : 0 ) ;
4853
};
4954

55+
// constructor
56+
PIXI.Point.prototype.constructor = PIXI.Point;

src/pixi/display/DisplayObject.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,8 @@ PIXI.DisplayObject.prototype.updateCache = function()
511511

512512
PIXI.DisplayObject.prototype._renderCachedSprite = function(renderSession)
513513
{
514+
this._cachedSprite.worldAlpha = this.worldAlpha;
515+
514516
if(renderSession.gl)
515517
{
516518
PIXI.Sprite.prototype._renderWebGL.call(this._cachedSprite, renderSession);

src/pixi/display/DisplayObjectContainer.js

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ PIXI.DisplayObjectContainer.prototype.constructor = PIXI.DisplayObjectContainer;
3636
* @type Number
3737
*/
3838

39-
/*
39+
4040
Object.defineProperty(PIXI.DisplayObjectContainer.prototype, 'width', {
4141
get: function() {
4242
return this.scale.x * this.getLocalBounds().width;
@@ -46,7 +46,7 @@ Object.defineProperty(PIXI.DisplayObjectContainer.prototype, 'width', {
4646
this._width = value;
4747
}
4848
});
49-
*/
49+
5050

5151
/**
5252
* The height of the displayObjectContainer, setting this will actually modify the scale to achieve the value set
@@ -55,7 +55,6 @@ Object.defineProperty(PIXI.DisplayObjectContainer.prototype, 'width', {
5555
* @type Number
5656
*/
5757

58-
/*
5958
Object.defineProperty(PIXI.DisplayObjectContainer.prototype, 'height', {
6059
get: function() {
6160
return this.scale.y * this.getLocalBounds().height;
@@ -65,7 +64,7 @@ Object.defineProperty(PIXI.DisplayObjectContainer.prototype, 'height', {
6564
this._height = value;
6665
}
6766
});
68-
*/
67+
6968

7069
/**
7170
* Adds a child to the container.
@@ -373,19 +372,21 @@ PIXI.DisplayObjectContainer.prototype._renderWebGL = function(renderSession)
373372

374373
if(this._mask || this._filters)
375374
{
375+
376+
// push filter first as we need to ensure the stencil buffer is correct for any masking
377+
if(this._filters)
378+
{
379+
renderSession.spriteBatch.flush();
380+
renderSession.filterManager.pushFilter(this._filterBlock);
381+
}
382+
376383
if(this._mask)
377384
{
378385
renderSession.spriteBatch.stop();
379386
renderSession.maskManager.pushMask(this.mask, renderSession);
380387
renderSession.spriteBatch.start();
381388
}
382389

383-
if(this._filters)
384-
{
385-
renderSession.spriteBatch.flush();
386-
renderSession.filterManager.pushFilter(this._filterBlock);
387-
}
388-
389390
// simple render children!
390391
for(i=0,j=this.children.length; i<j; i++)
391392
{
@@ -394,8 +395,8 @@ PIXI.DisplayObjectContainer.prototype._renderWebGL = function(renderSession)
394395

395396
renderSession.spriteBatch.stop();
396397

398+
if(this._mask)renderSession.maskManager.popMask(this._mask, renderSession);
397399
if(this._filters)renderSession.filterManager.popFilter();
398-
if(this._mask)renderSession.maskManager.popMask(renderSession);
399400

400401
renderSession.spriteBatch.start();
401402
}

0 commit comments

Comments
 (0)