|
1 | 1 | Phaser.Graphics = function (game, x, y) { |
2 | 2 |
|
3 | | - // If exists = false then the Sprite isn't updated by the core game loop or physics subsystem at all |
4 | | - this.exists = true; |
| 3 | + PIXI.Graphics.call(this); |
5 | 4 |
|
6 | | - // This is a handy little var your game can use to determine if a sprite is alive or not, it doesn't effect rendering |
7 | | - this.alive = true; |
8 | | - |
9 | | - this.group = null; |
10 | | - |
11 | | - this.name = ''; |
12 | | - |
13 | | - this.game = game; |
14 | | - |
15 | | - PIXI.DisplayObjectContainer.call(this); |
| 5 | + Phaser.Sprite.call(this, game, x, y); |
16 | 6 |
|
17 | 7 | this.type = Phaser.GRAPHICS; |
18 | 8 |
|
19 | | - this.position.x = x; |
20 | | - this.position.y = y; |
21 | | - |
22 | | - // Replaces the PIXI.Point with a slightly more flexible one |
23 | | - this.scale = new Phaser.Point(1, 1); |
24 | | - |
25 | | - // Influence of camera movement upon the position |
26 | | - this.scrollFactor = new Phaser.Point(1, 1); |
27 | | - |
28 | | - // A mini cache for storing all of the calculated values |
29 | | - this._cache = { |
30 | | - |
31 | | - dirty: false, |
32 | | - |
33 | | - // Transform cache |
34 | | - a00: 1, a01: 0, a02: x, a10: 0, a11: 1, a12: y, id: 1, |
35 | | - |
36 | | - // The previous calculated position inc. camera x/y and scrollFactor |
37 | | - x: -1, y: -1, |
38 | | - |
39 | | - // The actual scale values based on the worldTransform |
40 | | - scaleX: 1, scaleY: 1 |
41 | | - |
42 | | - }; |
43 | | - |
44 | | - this._cache.x = this.x - (this.game.world.camera.x * this.scrollFactor.x); |
45 | | - this._cache.y = this.y - (this.game.world.camera.y * this.scrollFactor.y); |
46 | | - |
47 | | - this.renderable = true; |
48 | | - |
49 | | - /** |
50 | | - * The alpha of the fill of this graphics object |
51 | | - * |
52 | | - * @property fillAlpha |
53 | | - * @type Number |
54 | | - */ |
55 | | - this.fillAlpha = 1; |
56 | | - |
57 | | - /** |
58 | | - * The width of any lines drawn |
59 | | - * |
60 | | - * @property lineWidth |
61 | | - * @type Number |
62 | | - */ |
63 | | - this.lineWidth = 0; |
64 | | - |
65 | | - /** |
66 | | - * The color of any lines drawn |
67 | | - * |
68 | | - * @property lineColor |
69 | | - * @type String |
70 | | - */ |
71 | | - this.lineColor = "black"; |
72 | | - |
73 | | - /** |
74 | | - * Graphics data |
75 | | - * |
76 | | - * @property graphicsData |
77 | | - * @type Array |
78 | | - * @private |
79 | | - */ |
80 | | - this.graphicsData = []; |
81 | | - |
82 | | - /** |
83 | | - * Current path |
84 | | - * |
85 | | - * @property currentPath |
86 | | - * @type Object |
87 | | - * @private |
88 | | - */ |
89 | | - this.currentPath = {points:[]}; |
90 | | - |
91 | 9 | }; |
92 | 10 |
|
93 | | -Phaser.Graphics.prototype = Phaser.Utils.extend(true, PIXI.Graphics.prototype, PIXI.DisplayObjectContainer.prototype, Phaser.Sprite.prototype); |
| 11 | +Phaser.Graphics.prototype = Object.create( PIXI.Graphics.prototype ); |
94 | 12 | Phaser.Graphics.prototype.constructor = Phaser.Graphics; |
95 | 13 |
|
| 14 | +Phaser.Graphics.prototype = Phaser.Utils.extend(true, Phaser.Graphics.prototype, Phaser.Sprite.prototype); |
| 15 | + |
96 | 16 | // Add our own custom methods |
97 | 17 |
|
98 | 18 | /** |
99 | 19 | * Automatically called by World.update |
100 | 20 | */ |
101 | | -Phaser.Graphics.prototype.update = function() { |
| 21 | +Phaser.Graphics.prototype.OLDupdate = function() { |
102 | 22 |
|
103 | | - if (!this.exists) |
104 | | - { |
105 | | - return; |
106 | | - } |
| 23 | + // if (!this.exists) |
| 24 | + // { |
| 25 | + // return; |
| 26 | + // } |
107 | 27 |
|
108 | | - this._cache.dirty = false; |
| 28 | + // this._cache.dirty = false; |
109 | 29 |
|
110 | | - this._cache.x = this.x - (this.game.world.camera.x * this.scrollFactor.x); |
111 | | - this._cache.y = this.y - (this.game.world.camera.y * this.scrollFactor.y); |
| 30 | + // this._cache.x = this.x - (this.game.world.camera.x * this.scrollFactor.x); |
| 31 | + // this._cache.y = this.y - (this.game.world.camera.y * this.scrollFactor.y); |
112 | 32 |
|
113 | | - if (this.position.x != this._cache.x || this.position.y != this._cache.y) |
114 | | - { |
115 | | - this.position.x = this._cache.x; |
116 | | - this.position.y = this._cache.y; |
117 | | - this._cache.dirty = true; |
118 | | - } |
| 33 | + // if (this.position.x != this._cache.x || this.position.y != this._cache.y) |
| 34 | + // { |
| 35 | + // this.position.x = this._cache.x; |
| 36 | + // this.position.y = this._cache.y; |
| 37 | + // this._cache.dirty = true; |
| 38 | + // } |
119 | 39 |
|
120 | 40 | } |
121 | 41 |
|
| 42 | +/* |
122 | 43 | Object.defineProperty(Phaser.Graphics.prototype, 'angle', { |
123 | 44 |
|
124 | 45 | get: function() { |
@@ -154,3 +75,5 @@ Object.defineProperty(Phaser.Graphics.prototype, 'y', { |
154 | 75 | } |
155 | 76 |
|
156 | 77 | }); |
| 78 | +
|
| 79 | +*/ |
0 commit comments