1- /**
2- * @author Richard Davey <rich@photonstorm.com>
3- * @copyright 2016 Photon Storm Ltd.
4- * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License }
5- */
61
2+ var Class = require ( '../utils/Class' ) ;
73var Extend = require ( '../utils/object/Extend' ) ;
84
95/**
@@ -18,156 +14,156 @@ var Extend = require('../utils/object/Extend');
1814* @param {number } width - Width of the frame within the Texture.
1915* @param {number } height - Height of the frame within the Texture.
2016*/
21- var Frame = function ( texture , name , sourceIndex , x , y , width , height )
22- {
23- /**
24- * @property {Phaser.Texture } texture - The Texture this frame belongs to.
25- */
26- this . texture = texture ;
27-
28- /**
29- * @property {string } name - The name of this frame within the Texture.
30- */
31- this . name = name ;
32-
33- this . source = texture . source [ sourceIndex ] ;
34-
35- this . sourceIndex = sourceIndex ;
36-
37- /**
38- * @property {number } cutX - X position within the source image to cut from.
39- */
40- this . cutX = x ;
41-
42- /**
43- * @property {number } cutY - Y position within the source image to cut from.
44- */
45- this . cutY = y ;
46-
47- /**
48- * @property {number } cutWidth - The width of the area in the source image to cut.
49- */
50- this . cutWidth = width ;
17+ var Frame = new Class ( {
5118
52- /**
53- * @property {number } cutHeight - The height of the area in the source image to cut.
54- */
55- this . cutHeight = height ;
56-
57- /**
58- * @property {number } x - The X rendering offset of this Frame, taking trim into account.
59- */
60- this . x = 0 ;
61-
62- /**
63- * @property {number } y - The Y rendering offset of this Frame, taking trim into account.
64- */
65- this . y = 0 ;
66-
67- /**
68- * @property {number } width - The rendering width of this Frame, taking trim into account.
69- */
70- this . width = width ;
71-
72- /**
73- * @property {number } height - The rendering height of this Frame, taking trim into account.
74- */
75- this . height = height ;
19+ initialize :
7620
77- /**
78- * @property {number } width - The rendering width of this Frame, taking trim into account.
79- */
80- this . centerX = Math . floor ( width / 2 ) ;
81-
82- /**
83- * @property {number } height - The rendering height of this Frame, taking trim into account.
84- */
85- this . centerY = Math . floor ( height / 2 ) ;
86-
87- /**
88- * Is this frame is rotated or not in the Texture?
89- * Rotation allows you to use rotated frames in texture atlas packing.
90- * It has nothing to do with Sprite rotation.
91- *
92- * @property {boolean } rotated
93- * @default
94- */
95- this . rotated = false ;
96-
97- /**
98- * Is this a tiling texture? As used by the likes of a TilingSprite.
99- * TODO: Try and remove this, it shouldn't be here
100- *
101- * @property {boolean } isTiling
102- * @default
103- */
104- this . isTiling = false ;
105-
106- /**
107- * This will let a renderer know that a tinted parent has updated its texture.
108- * TODO: Try and remove this, it shouldn't be here
109- *
110- * @property {boolean } requiresReTint
111- * @default
112- */
113- this . requiresReTint = false ;
114-
115- // Over-rides the Renderer setting? -1 = use Renderer Setting, 0 = No rounding, 1 = Round
116- this . autoRound = - 1 ;
117-
118- /**
119- * The un-modified source frame, trim and UV data.
120- *
121- * @private
122- * @property {object } data
123- */
124- this . data = {
125- cut : {
126- x : x ,
127- y : y ,
128- w : width ,
129- h : height ,
130- r : x + width ,
131- b : y + height
132- } ,
133- trim : false ,
134- sourceSize : {
135- w : width ,
136- h : height
137- } ,
138- spriteSourceSize : {
139- x : 0 ,
140- y : 0 ,
141- w : width ,
142- h : height
143- } ,
144- uvs : {
145- x0 : 0 ,
146- y0 : 0 ,
147- x1 : 0 ,
148- y1 : 0 ,
149- x2 : 0 ,
150- y2 : 0 ,
151- x3 : 0 ,
152- y3 : 0
153- } ,
154- radius : 0.5 * Math . sqrt ( width * width + height * height ) ,
155- drawImage : {
156- sx : x ,
157- sy : y ,
158- sWidth : width ,
159- sHeight : height ,
160- dWidth : width ,
161- dHeight : height
162- }
163- } ;
164-
165- this . updateUVs ( ) ;
166- } ;
167-
168- Frame . prototype . constructor = Frame ;
21+ function Frame ( texture , name , sourceIndex , x , y , width , height )
22+ {
23+ /**
24+ * @property {Phaser.Texture } texture - The Texture this frame belongs to.
25+ */
26+ this . texture = texture ;
27+
28+ /**
29+ * @property {string } name - The name of this frame within the Texture.
30+ */
31+ this . name = name ;
32+
33+ this . source = texture . source [ sourceIndex ] ;
34+
35+ this . sourceIndex = sourceIndex ;
36+
37+ /**
38+ * @property {number } cutX - X position within the source image to cut from.
39+ */
40+ this . cutX = x ;
41+
42+ /**
43+ * @property {number } cutY - Y position within the source image to cut from.
44+ */
45+ this . cutY = y ;
46+
47+ /**
48+ * @property {number } cutWidth - The width of the area in the source image to cut.
49+ */
50+ this . cutWidth = width ;
51+
52+ /**
53+ * @property {number } cutHeight - The height of the area in the source image to cut.
54+ */
55+ this . cutHeight = height ;
56+
57+ /**
58+ * @property {number } x - The X rendering offset of this Frame, taking trim into account.
59+ */
60+ this . x = 0 ;
61+
62+ /**
63+ * @property {number } y - The Y rendering offset of this Frame, taking trim into account.
64+ */
65+ this . y = 0 ;
66+
67+ /**
68+ * @property {number } width - The rendering width of this Frame, taking trim into account.
69+ */
70+ this . width = width ;
71+
72+ /**
73+ * @property {number } height - The rendering height of this Frame, taking trim into account.
74+ */
75+ this . height = height ;
76+
77+ /**
78+ * @property {number } width - The rendering width of this Frame, taking trim into account.
79+ */
80+ this . centerX = Math . floor ( width / 2 ) ;
81+
82+ /**
83+ * @property {number } height - The rendering height of this Frame, taking trim into account.
84+ */
85+ this . centerY = Math . floor ( height / 2 ) ;
86+
87+ /**
88+ * Is this frame is rotated or not in the Texture?
89+ * Rotation allows you to use rotated frames in texture atlas packing.
90+ * It has nothing to do with Sprite rotation.
91+ *
92+ * @property {boolean } rotated
93+ * @default
94+ */
95+ this . rotated = false ;
96+
97+ /**
98+ * Is this a tiling texture? As used by the likes of a TilingSprite.
99+ * TODO: Try and remove this, it shouldn't be here
100+ *
101+ * @property {boolean } isTiling
102+ * @default
103+ */
104+ this . isTiling = false ;
105+
106+ /**
107+ * This will let a renderer know that a tinted parent has updated its texture.
108+ * TODO: Try and remove this, it shouldn't be here
109+ *
110+ * @property {boolean } requiresReTint
111+ * @default
112+ */
113+ this . requiresReTint = false ;
114+
115+ // Over-rides the Renderer setting? -1 = use Renderer Setting, 0 = No rounding, 1 = Round
116+ this . autoRound = - 1 ;
117+
118+ /**
119+ * The un-modified source frame, trim and UV data.
120+ *
121+ * @private
122+ * @property {object } data
123+ */
124+ this . data = {
125+ cut : {
126+ x : x ,
127+ y : y ,
128+ w : width ,
129+ h : height ,
130+ r : x + width ,
131+ b : y + height
132+ } ,
133+ trim : false ,
134+ sourceSize : {
135+ w : width ,
136+ h : height
137+ } ,
138+ spriteSourceSize : {
139+ x : 0 ,
140+ y : 0 ,
141+ w : width ,
142+ h : height
143+ } ,
144+ uvs : {
145+ x0 : 0 ,
146+ y0 : 0 ,
147+ x1 : 0 ,
148+ y1 : 0 ,
149+ x2 : 0 ,
150+ y2 : 0 ,
151+ x3 : 0 ,
152+ y3 : 0
153+ } ,
154+ radius : 0.5 * Math . sqrt ( width * width + height * height ) ,
155+ drawImage : {
156+ sx : x ,
157+ sy : y ,
158+ sWidth : width ,
159+ sHeight : height ,
160+ dWidth : width ,
161+ dHeight : height
162+ }
163+ } ;
169164
170- Frame . prototype = {
165+ this . updateUVs ( ) ;
166+ } ,
171167
172168 /**
173169 * If the frame was trimmed when added to the Texture Atlas, this records the trim and source data.
@@ -295,11 +291,7 @@ Frame.prototype = {
295291
296292 destroy : function ( )
297293 {
298- }
299-
300- } ;
301-
302- Object . defineProperties ( Frame . prototype , {
294+ } ,
303295
304296 /**
305297 * The width of the Frame in its un-trimmed, un-padded state, as prepared in the art package,
@@ -310,8 +302,6 @@ Object.defineProperties(Frame.prototype, {
310302 */
311303 realWidth : {
312304
313- enumerable : true ,
314-
315305 get : function ( )
316306 {
317307 return this . data . sourceSize . w ;
@@ -328,8 +318,6 @@ Object.defineProperties(Frame.prototype, {
328318 */
329319 realHeight : {
330320
331- enumerable : true ,
332-
333321 get : function ( )
334322 {
335323 return this . data . sourceSize . h ;
@@ -345,8 +333,6 @@ Object.defineProperties(Frame.prototype, {
345333 */
346334 uvs : {
347335
348- enumerable : true ,
349-
350336 get : function ( )
351337 {
352338 return this . data . uvs ;
@@ -361,8 +347,6 @@ Object.defineProperties(Frame.prototype, {
361347 */
362348 radius : {
363349
364- enumerable : true ,
365-
366350 get : function ( )
367351 {
368352 return this . data . radius ;
@@ -377,8 +361,6 @@ Object.defineProperties(Frame.prototype, {
377361 */
378362 trimmed : {
379363
380- enumerable : true ,
381-
382364 get : function ( )
383365 {
384366 return this . data . trim ;
@@ -394,8 +376,6 @@ Object.defineProperties(Frame.prototype, {
394376 */
395377 canvasData : {
396378
397- enumerable : true ,
398-
399379 get : function ( )
400380 {
401381 return this . data . drawImage ;
0 commit comments