Skip to content

Commit 4fc26e4

Browse files
committed
Updated to the latest version of Pixi.
1 parent dd88f2a commit 4fc26e4

23 files changed

Lines changed: 308 additions & 1253 deletions

build/config.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
<script src="$path/src/pixi/renderers/webgl/shaders/ComplexPrimitiveShader.js"></script>
5353
<script src="$path/src/pixi/renderers/webgl/utils/WebGLGraphics.js"></script>
5454
<script src="$path/src/pixi/renderers/webgl/WebGLRenderer.js"></script>
55+
<script src="$path/src/pixi/renderers/webgl/utils/WebGLBlendModeManager.js"></script>
5556
<script src="$path/src/pixi/renderers/webgl/utils/WebGLMaskManager.js"></script>
5657
<script src="$path/src/pixi/renderers/webgl/utils/WebGLStencilManager.js"></script>
5758
<script src="$path/src/pixi/renderers/webgl/utils/WebGLShaderManager.js"></script>

src/gameobjects/Sprite.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,11 @@ Phaser.Sprite.prototype.setFrame = function(frame) {
449449
this.texture.frame.width = frame.width;
450450
this.texture.frame.height = frame.height;
451451

452+
this.texture.crop.x = frame.x;
453+
this.texture.crop.y = frame.y;
454+
this.texture.crop.width = frame.width;
455+
this.texture.crop.height = frame.height;
456+
452457
if (frame.trimmed)
453458
{
454459
if (this.texture.trim)
@@ -462,6 +467,11 @@ Phaser.Sprite.prototype.setFrame = function(frame) {
462467
{
463468
this.texture.trim = { x: frame.spriteSourceSizeX, y: frame.spriteSourceSizeY, width: frame.sourceSizeW, height: frame.sourceSizeH };
464469
}
470+
471+
this.texture.width = frame.sourceSizeW;
472+
this.texture.height = frame.sourceSizeH;
473+
this.texture.frame.width = frame.sourceSizeW;
474+
this.texture.frame.height = frame.sourceSizeH;
465475
}
466476

467477
if (this.cropRect)

src/gameobjects/TileSprite.js

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -386,27 +386,44 @@ Phaser.TileSprite.prototype.setFrame = function(frame) {
386386
// this._cache[12] = frame.height;
387387
// this._cache[13] = frame.spriteSourceSizeX;
388388
// this._cache[14] = frame.spriteSourceSizeY;
389+
// this._cache[17] = frame.sourceSizeW;
390+
// this._cache[18] = frame.sourceSizeH;
389391

390392
this.texture.frame.x = frame.x;
391393
this.texture.frame.y = frame.y;
392394
this.texture.frame.width = frame.width;
393395
this.texture.frame.height = frame.height;
394396

397+
this.texture.crop.x = frame.x;
398+
this.texture.crop.y = frame.y;
399+
this.texture.crop.width = frame.width;
400+
this.texture.crop.height = frame.height;
401+
395402
if (frame.trimmed)
396403
{
397-
this.texture.trim = { x: frame.spriteSourceSizeX, y: frame.spriteSourceSizeY, width: frame.width, height: frame.height };
404+
if (this.texture.trim)
405+
{
406+
this.texture.trim.x = frame.spriteSourceSizeX;
407+
this.texture.trim.y = frame.spriteSourceSizeY;
408+
this.texture.trim.width = frame.sourceSizeW;
409+
this.texture.trim.height = frame.sourceSizeH;
410+
}
411+
else
412+
{
413+
this.texture.trim = { x: frame.spriteSourceSizeX, y: frame.spriteSourceSizeY, width: frame.sourceSizeW, height: frame.sourceSizeH };
414+
}
415+
416+
this.texture.width = frame.sourceSizeW;
417+
this.texture.height = frame.sourceSizeH;
418+
this.texture.frame.width = frame.sourceSizeW;
419+
this.texture.frame.height = frame.sourceSizeH;
398420
}
399421

400422
if (this.game.renderType === Phaser.WEBGL)
401423
{
402424
PIXI.WebGLRenderer.updateTextureFrame(this.texture);
403425
}
404426

405-
// if (this.cropRect)
406-
// {
407-
// this.updateCrop();
408-
// }
409-
410427
};
411428

412429
/**

src/particles/arcade/Emitter.js

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,10 @@ Phaser.Particles.Arcade.Emitter = function (game, x, y, maxParticles) {
4141
this.type = Phaser.EMITTER;
4242

4343
/**
44-
* @property {number} width - The width of the emitter. Particles can be randomly generated from anywhere within this box.
44+
* @property {Phaser.Rectangle} area - The area of the emitter. Particles can be randomly generated from anywhere within this rectangle.
4545
* @default
4646
*/
47-
this.width = 1;
48-
49-
/**
50-
* @property {number} height - The height of the emitter. Particles can be randomly generated from anywhere within this box.
51-
* @default
52-
*/
53-
this.height = 1;
47+
this.area = new Phaser.Rectangle(x, y, 1, 1);
5448

5549
/**
5650
* @property {Phaser.Point} minParticleSpeed - The minimum possible velocity of a particle.
@@ -555,14 +549,15 @@ Phaser.Particles.Arcade.Emitter.prototype.emitParticle = function () {
555549

556550
/**
557551
* A more compact way of setting the width and height of the emitter.
552+
*
558553
* @method Phaser.Particles.Arcade.Emitter#setSize
559554
* @param {number} width - The desired width of the emitter (particles are spawned randomly within these dimensions).
560555
* @param {number} height - The desired height of the emitter.
561556
*/
562557
Phaser.Particles.Arcade.Emitter.prototype.setSize = function (width, height) {
563558

564-
this.width = width;
565-
this.height = height;
559+
this.area.width = width;
560+
this.area.height = height;
566561

567562
};
568563

@@ -764,7 +759,7 @@ Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype, "y", {
764759
Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype, "left", {
765760

766761
get: function () {
767-
return Math.floor(this.x - (this.width / 2));
762+
return Math.floor(this.x - (this.area.width / 2));
768763
}
769764

770765
});
@@ -777,7 +772,7 @@ Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype, "left", {
777772
Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype, "right", {
778773

779774
get: function () {
780-
return Math.floor(this.x + (this.width / 2));
775+
return Math.floor(this.x + (this.area.width / 2));
781776
}
782777

783778
});
@@ -790,7 +785,7 @@ Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype, "right", {
790785
Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype, "top", {
791786

792787
get: function () {
793-
return Math.floor(this.y - (this.height / 2));
788+
return Math.floor(this.y - (this.area.height / 2));
794789
}
795790

796791
});
@@ -803,7 +798,7 @@ Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype, "top", {
803798
Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype, "bottom", {
804799

805800
get: function () {
806-
return Math.floor(this.y + (this.height / 2));
801+
return Math.floor(this.y + (this.area.height / 2));
807802
}
808803

809804
});

src/pixi/Pixi.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ PIXI.sayHello = function (type)
6969
if ( navigator.userAgent.toLowerCase().indexOf('chrome') > -1 )
7070
{
7171
var args = [
72-
'%c %c %c Pixi.js ' + PIXI.VERSION + ' - ' + type + ' %c ' + ' %c ' + ' http://pixjs.com %c %c ♥%c♥%c♥ ',
72+
'%c %c %c Pixi.js ' + PIXI.VERSION + ' - ' + type + ' %c ' + ' %c ' + ' http://pixijs.com %c %c ♥%c♥%c♥ ',
7373
'background: #ff66a5',
7474
'background: #ff66a5',
7575
'color: #ff66a5; background: #030307;',

src/pixi/display/DisplayObject.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,6 @@ PIXI.DisplayObject.prototype.updateTransform = function()
425425
// TODO OPTIMIZE THIS!! with dirty
426426
if(this.rotation !== this.rotationCache)
427427
{
428-
429428
this.rotationCache = this.rotation;
430429
this._sr = Math.sin(this.rotation);
431430
this._cr = Math.cos(this.rotation);

src/pixi/display/Sprite.js

Lines changed: 48 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,6 @@ PIXI.Sprite.prototype.onTextureUpdate = function()
172172
*/
173173
PIXI.Sprite.prototype.getBounds = function(matrix)
174174
{
175-
176175
var width = this.texture.frame.width;
177176
var height = this.texture.frame.height;
178177

@@ -320,31 +319,30 @@ PIXI.Sprite.prototype._renderCanvas = function(renderSession)
320319
// if the sprite is not visible or the alpha is 0 then no need to render this element
321320
if(this.visible === false || this.alpha === 0)return;
322321

323-
var frame = this.texture.frame;
324322
var context = renderSession.context;
325323
var texture = this.texture;
324+
var frame = texture.frame;
325+
var crop = texture.crop;
326326

327-
if(this.blendMode !== renderSession.currentBlendMode)
327+
if (this.blendMode !== renderSession.currentBlendMode)
328328
{
329329
renderSession.currentBlendMode = this.blendMode;
330330
context.globalCompositeOperation = PIXI.blendModesCanvas[renderSession.currentBlendMode];
331331
}
332332

333-
if(this._mask)
333+
if (this._mask)
334334
{
335335
renderSession.maskManager.pushMask(this._mask, renderSession.context);
336336
}
337337

338-
339-
340-
//ignore null sources
341-
if(texture.valid)
338+
// Ignore null sources
339+
if (texture.valid)
342340
{
343341
context.globalAlpha = this.worldAlpha;
344342

345343
var transform = this.worldTransform;
346344

347-
// allow for trimming
345+
// Allow for trimming
348346
if (renderSession.roundPixels)
349347
{
350348
context.setTransform(transform.a, transform.c, transform.b, transform.d, transform.tx | 0, transform.ty | 0);
@@ -354,28 +352,41 @@ PIXI.Sprite.prototype._renderCanvas = function(renderSession)
354352
context.setTransform(transform.a, transform.c, transform.b, transform.d, transform.tx, transform.ty);
355353
}
356354

357-
//if smoothingEnabled is supported and we need to change the smoothing property for this texture
358-
if(renderSession.smoothProperty && renderSession.scaleMode !== this.texture.baseTexture.scaleMode) {
355+
// If smoothingEnabled is supported and we need to change the smoothing property for this texture
356+
if (renderSession.smoothProperty && renderSession.scaleMode !== this.texture.baseTexture.scaleMode)
357+
{
359358
renderSession.scaleMode = this.texture.baseTexture.scaleMode;
360359
context[renderSession.smoothProperty] = (renderSession.scaleMode === PIXI.scaleModes.LINEAR);
361360
}
362361

363-
if(this.tint !== 0xFFFFFF)
362+
if (this.tint !== 0xFFFFFF)
364363
{
365-
366-
if(this.cachedTint !== this.tint)
364+
if (this.cachedTint !== this.tint)
367365
{
368366
// no point tinting an image that has not loaded yet!
369-
if(!texture.baseTexture.hasLoaded)return;
367+
if (!texture.baseTexture.hasLoaded) return;
370368

371369
this.cachedTint = this.tint;
372370

373371
//TODO clean up caching - how to clean up the caches?
374372
this.tintedTexture = PIXI.CanvasTinter.getTintedTexture(this, this.tint);
375-
376373
}
377374

378-
context.drawImage(this.tintedTexture,
375+
if (texture.trim)
376+
{
377+
context.drawImage(this.tintedTexture,
378+
0,
379+
0,
380+
crop.width,
381+
crop.height,
382+
texture.trim.x - this.anchor.x * texture.trim.width,
383+
texture.trim.y - this.anchor.y * texture.trim.height,
384+
crop.width,
385+
crop.height);
386+
}
387+
else
388+
{
389+
context.drawImage(this.tintedTexture,
379390
0,
380391
0,
381392
frame.width,
@@ -384,57 +395,50 @@ PIXI.Sprite.prototype._renderCanvas = function(renderSession)
384395
(this.anchor.y) * -frame.height,
385396
frame.width,
386397
frame.height);
398+
}
387399
}
388400
else
389401
{
390-
391-
392-
393-
if(texture.trim)
402+
if (texture.trim)
394403
{
395-
var trim = texture.trim;
396-
397404
context.drawImage(this.texture.baseTexture.source,
398-
frame.x,
399-
frame.y,
400-
frame.width,
401-
frame.height,
402-
trim.x - this.anchor.x * trim.width,
403-
trim.y - this.anchor.y * trim.height,
404-
frame.width,
405-
frame.height);
405+
crop.x,
406+
crop.y,
407+
crop.width,
408+
crop.height,
409+
texture.trim.x - this.anchor.x * texture.trim.width,
410+
texture.trim.y - this.anchor.y * texture.trim.height,
411+
crop.width,
412+
crop.height);
406413
}
407414
else
408415
{
409-
410416
context.drawImage(this.texture.baseTexture.source,
411-
frame.x,
412-
frame.y,
413-
frame.width,
414-
frame.height,
415-
(this.anchor.x) * -frame.width,
416-
(this.anchor.y) * -frame.height,
417-
frame.width,
418-
frame.height);
417+
crop.x,
418+
crop.y,
419+
crop.width,
420+
crop.height,
421+
this.anchor.x * -frame.width,
422+
this.anchor.y * -frame.height,
423+
crop.width,
424+
crop.height);
419425
}
420-
421426
}
422427
}
423428

424429
// OVERWRITE
425-
for(var i=0,j=this.children.length; i<j; i++)
430+
for (var i = 0, j = this.children.length; i < j; i++)
426431
{
427432
var child = this.children[i];
428433
child._renderCanvas(renderSession);
429434
}
430435

431-
if(this._mask)
436+
if (this._mask)
432437
{
433438
renderSession.maskManager.popMask(renderSession.context);
434439
}
435440
};
436441

437-
438442
// some helper functions..
439443

440444
/**

src/pixi/display/Stage.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ PIXI.Stage = function(backgroundColor)
4343
/**
4444
* The interaction manage for this stage, manages all interactive activity on the stage
4545
*
46-
* @property interactive
46+
* @property interactionManager
4747
* @type InteractionManager
4848
*/
4949
this.interactionManager = new PIXI.InteractionManager(this);

0 commit comments

Comments
 (0)