Skip to content

Commit 86f972a

Browse files
committed
Updated to latest Pixi dev branch.
1 parent 2124365 commit 86f972a

17 files changed

Lines changed: 167 additions & 90 deletions

src/pixi/InteractionManager.js

Lines changed: 52 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -253,19 +253,7 @@ PIXI.InteractionManager.prototype.update = function()
253253
// OPTIMISE - how often to check??
254254
if(this.dirty)
255255
{
256-
this.dirty = false;
257-
258-
var len = this.interactiveItems.length;
259-
260-
for (i = 0; i < len; i++) {
261-
this.interactiveItems[i].interactiveChildren = false;
262-
}
263-
264-
this.interactiveItems = [];
265-
266-
if(this.stage.interactive)this.interactiveItems.push(this.stage);
267-
// go through and collect all the objects that are interactive..
268-
this.collectInteractiveSprite(this.stage, this.stage);
256+
this.rebuildInteractiveGraph();
269257
}
270258

271259
// loop through interactive objects!
@@ -317,6 +305,23 @@ PIXI.InteractionManager.prototype.update = function()
317305
}
318306
};
319307

308+
PIXI.InteractionManager.prototype.rebuildInteractiveGraph = function()
309+
{
310+
this.dirty = false;
311+
312+
var len = this.interactiveItems.length;
313+
314+
for (var i = 0; i < len; i++) {
315+
this.interactiveItems[i].interactiveChildren = false;
316+
}
317+
318+
this.interactiveItems = [];
319+
320+
if(this.stage.interactive)this.interactiveItems.push(this.stage);
321+
// go through and collect all the objects that are interactive..
322+
this.collectInteractiveSprite(this.stage, this.stage);
323+
};
324+
320325
/**
321326
* Is called when the mouse moves across the renderer element
322327
*
@@ -326,6 +331,11 @@ PIXI.InteractionManager.prototype.update = function()
326331
*/
327332
PIXI.InteractionManager.prototype.onMouseMove = function(event)
328333
{
334+
if(this.dirty)
335+
{
336+
this.rebuildInteractiveGraph();
337+
}
338+
329339
this.mouse.originalEvent = event || window.event; //IE uses window.event
330340
// TODO optimize by not check EVERY TIME! maybe half as often? //
331341
var rect = this.interactionDOMElement.getBoundingClientRect();
@@ -356,6 +366,11 @@ PIXI.InteractionManager.prototype.onMouseMove = function(event)
356366
*/
357367
PIXI.InteractionManager.prototype.onMouseDown = function(event)
358368
{
369+
if(this.dirty)
370+
{
371+
this.rebuildInteractiveGraph();
372+
}
373+
359374
this.mouse.originalEvent = event || window.event; //IE uses window.event
360375

361376
if(PIXI.AUTO_PREVENT_DEFAULT)this.mouse.originalEvent.preventDefault();
@@ -399,6 +414,11 @@ PIXI.InteractionManager.prototype.onMouseDown = function(event)
399414
*/
400415
PIXI.InteractionManager.prototype.onMouseOut = function()
401416
{
417+
if(this.dirty)
418+
{
419+
this.rebuildInteractiveGraph();
420+
}
421+
402422
var length = this.interactiveItems.length;
403423

404424
this.interactionDOMElement.style.cursor = 'inherit';
@@ -430,6 +450,10 @@ PIXI.InteractionManager.prototype.onMouseOut = function()
430450
*/
431451
PIXI.InteractionManager.prototype.onMouseUp = function(event)
432452
{
453+
if(this.dirty)
454+
{
455+
this.rebuildInteractiveGraph();
456+
}
433457

434458
this.mouse.originalEvent = event || window.event; //IE uses window.event
435459

@@ -553,6 +577,11 @@ PIXI.InteractionManager.prototype.hitTest = function(item, interactionData)
553577
*/
554578
PIXI.InteractionManager.prototype.onTouchMove = function(event)
555579
{
580+
if(this.dirty)
581+
{
582+
this.rebuildInteractiveGraph();
583+
}
584+
556585
var rect = this.interactionDOMElement.getBoundingClientRect();
557586
var changedTouches = event.changedTouches;
558587
var touchData;
@@ -589,6 +618,11 @@ PIXI.InteractionManager.prototype.onTouchMove = function(event)
589618
*/
590619
PIXI.InteractionManager.prototype.onTouchStart = function(event)
591620
{
621+
if(this.dirty)
622+
{
623+
this.rebuildInteractiveGraph();
624+
}
625+
592626
var rect = this.interactionDOMElement.getBoundingClientRect();
593627

594628
if(PIXI.AUTO_PREVENT_DEFAULT)event.preventDefault();
@@ -645,6 +679,11 @@ PIXI.InteractionManager.prototype.onTouchStart = function(event)
645679
*/
646680
PIXI.InteractionManager.prototype.onTouchEnd = function(event)
647681
{
682+
if(this.dirty)
683+
{
684+
this.rebuildInteractiveGraph();
685+
}
686+
648687
//this.mouse.originalEvent = event || window.event; //IE uses window.event
649688
var rect = this.interactionDOMElement.getBoundingClientRect();
650689
var changedTouches = event.changedTouches;

src/pixi/Pixi.js

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,18 +59,23 @@ PIXI.AUTO_PREVENT_DEFAULT = true;
5959
PIXI.RAD_TO_DEG = 180 / Math.PI;
6060
PIXI.DEG_TO_RAD = Math.PI / 180;
6161

62-
PIXI.sayHello = function ()
62+
63+
PIXI.dontSayHello = false;
64+
65+
PIXI.sayHello = function (type)
6366
{
67+
if(PIXI.dontSayHello)return;
68+
6469
if ( navigator.userAgent.toLowerCase().indexOf('chrome') > -1 )
6570
{
6671
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',
72+
'%c %c %c Pixi.js ' + PIXI.VERSION + ' - ' + type + ' %c ' + ' %c ' + ' http://pixjs.com %c %c ♥%c♥%c♥ ',
73+
'background: #ff66a5',
74+
'background: #ff66a5',
75+
'color: #ff66a5; background: #030307;',
76+
'background: #ff66a5',
77+
'background: #ffc3dc',
78+
'background: #ff66a5',
7479
'color: #ff2424; background: #fff',
7580
'color: #ff2424; background: #fff',
7681
'color: #ff2424; background: #fff'
@@ -84,6 +89,6 @@ PIXI.sayHello = function ()
8489
{
8590
console.log('Pixi.js ' + PIXI.VERSION + ' - http://pixjs.com');
8691
}
87-
};
8892

89-
PIXI.sayHello();
93+
PIXI.dontSayHello = true;
94+
};

src/pixi/core/Circle.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,17 @@ PIXI.Circle.prototype.contains = function(x, y)
6969
return (dx + dy <= r2);
7070
};
7171

72+
/**
73+
* Returns the framing rectangle of the circle as a PIXI.Rectangle object
74+
*
75+
* @method getBounds
76+
* @return {Rectangle} the framing rectangle
77+
*/
78+
PIXI.Circle.prototype.getBounds = function()
79+
{
80+
return new PIXI.Rectangle(this.x - this.radius, this.y - this.radius, this.width, this.height);
81+
};
82+
7283
// constructor
7384
PIXI.Circle.prototype.constructor = PIXI.Circle;
7485

src/pixi/core/Ellipse.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
*
88
* @class Ellipse
99
* @constructor
10-
* @param x {Number} The X coordinate of the upper-left corner of the framing rectangle of this ellipse
11-
* @param y {Number} The Y coordinate of the upper-left corner of the framing rectangle of this ellipse
12-
* @param width {Number} The overall width of this ellipse
13-
* @param height {Number} The overall height of this ellipse
10+
* @param x {Number} The X coordinate of the center of the ellipse
11+
* @param y {Number} The Y coordinate of the center of the ellipse
12+
* @param width {Number} The half width of this ellipse
13+
* @param height {Number} The half height of this ellipse
1414
*/
1515
PIXI.Ellipse = function(x, y, width, height)
1616
{
@@ -85,7 +85,7 @@ PIXI.Ellipse.prototype.contains = function(x, y)
8585
*/
8686
PIXI.Ellipse.prototype.getBounds = function()
8787
{
88-
return new PIXI.Rectangle(this.x, this.y, this.width, this.height);
88+
return new PIXI.Rectangle(this.x - this.width, this.y - this.height, this.width, this.height);
8989
};
9090

9191
// constructor

src/pixi/display/DisplayObjectContainer.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ Object.defineProperty(PIXI.DisplayObjectContainer.prototype, 'height', {
7474
*/
7575
PIXI.DisplayObjectContainer.prototype.addChild = function(child)
7676
{
77-
this.addChildAt(child, this.children.length);
77+
return this.addChildAt(child, this.children.length);
7878
};
7979

8080
/**
@@ -98,6 +98,8 @@ PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index)
9898
this.children.splice(index, 0, child);
9999

100100
if(this.stage)child.setStageReference(this.stage);
101+
102+
return child;
101103
}
102104
else
103105
{

src/pixi/display/Sprite.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ PIXI.Sprite.prototype.onTextureUpdate = function()
160160
if(this._height)this.scale.y = this._height / this.texture.frame.height;
161161

162162

163-
this.updateFrame = true;
163+
//this.updateFrame = true;
164164
};
165165

166166
/**

src/pixi/extras/Rope.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,5 +167,5 @@ PIXI.Rope.prototype.setTexture = function(texture)
167167
{
168168
// stop current texture
169169
this.texture = texture;
170-
this.updateFrame = true;
170+
//this.updateFrame = true;
171171
};

src/pixi/extras/TilingSprite.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ Object.defineProperty(PIXI.TilingSprite.prototype, 'height', {
130130
*/
131131
PIXI.TilingSprite.prototype.onTextureUpdate = function()
132132
{
133-
this.updateFrame = true;
133+
//this.updateFrame = true;
134134
};
135135

136136
PIXI.TilingSprite.prototype.setTexture = function(texture)

src/pixi/primitives/Graphics.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ PIXI.Graphics.prototype.drawRoundedRect = function( x, y, width, height, radius
527527
* @param y {Number} The Y coordinate of the center of the circle
528528
* @param radius {Number} The radius of the circle
529529
*/
530-
PIXI.Graphics.prototype.drawCircle = function( x, y, radius)
530+
PIXI.Graphics.prototype.drawCircle = function(x, y, radius)
531531
{
532532

533533
if (!this.currentPath.points.length) this.graphicsData.pop();
@@ -546,12 +546,12 @@ PIXI.Graphics.prototype.drawCircle = function( x, y, radius)
546546
* Draws an ellipse.
547547
*
548548
* @method drawEllipse
549-
* @param x {Number} The X coordinate of the upper-left corner of the framing rectangle of this ellipse
550-
* @param y {Number} The Y coordinate of the upper-left corner of the framing rectangle of this ellipse
551-
* @param width {Number} The width of the ellipse
552-
* @param height {Number} The height of the ellipse
549+
* @param x {Number} The X coordinate of the center of the ellipse
550+
* @param y {Number} The Y coordinate of the center of the ellipse
551+
* @param width {Number} The half width of the ellipse
552+
* @param height {Number} The half height of the ellipse
553553
*/
554-
PIXI.Graphics.prototype.drawEllipse = function( x, y, width, height)
554+
PIXI.Graphics.prototype.drawEllipse = function(x, y, width, height)
555555
{
556556

557557
if (!this.currentPath.points.length) this.graphicsData.pop();

src/pixi/renderers/canvas/CanvasRenderer.js

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@
1515
*/
1616
PIXI.CanvasRenderer = function(width, height, view, transparent)
1717
{
18-
PIXI.defaultRenderer = PIXI.defaultRenderer || this;
18+
if(!PIXI.defaultRenderer)
19+
{
20+
PIXI.sayHello("Canvas");
21+
PIXI.defaultRenderer = this;
22+
}
1923

2024
this.type = PIXI.CANVAS_RENDERER;
2125

@@ -31,16 +35,6 @@ PIXI.CanvasRenderer = function(width, height, view, transparent)
3135
*/
3236
this.clearBeforeRender = true;
3337

34-
/**
35-
* If true Pixi will Math.floor() x/y values when rendering, stopping pixel interpolation.
36-
* Handy for crisp pixel art and speed on legacy devices.
37-
*
38-
* @property roundPixels
39-
* @type Boolean
40-
* @default
41-
*/
42-
this.roundPixels = false;
43-
4438
/**
4539
* Whether the render view is transparent
4640
*
@@ -153,7 +147,14 @@ PIXI.CanvasRenderer = function(width, height, view, transparent)
153147
context: this.context,
154148
maskManager: this.maskManager,
155149
scaleMode: null,
156-
smoothProperty: null
150+
smoothProperty: null,
151+
152+
/**
153+
* If true Pixi will Math.floor() x/y values when rendering, stopping pixel interpolation.
154+
* Handy for crisp pixel art and speed on legacy devices.
155+
*
156+
*/
157+
roundPixels: false
157158
};
158159

159160
if("imageSmoothingEnabled" in this.context)

0 commit comments

Comments
 (0)