@@ -22,8 +22,7 @@ var Line = require('../../geom/line/Line');
2222 *
2323 * @extends Phaser.GameObjects.Components.AlphaSingle
2424 * @extends Phaser.GameObjects.Components.BlendMode
25- * @extends Phaser.GameObjects.Components.ComputedSize
26- * @extends Phaser.GameObjects.Components.Depth
25+ * @extends Phaser.GameObjects.Components.Depth
2726 * @extends Phaser.GameObjects.Components.GetBounds
2827 * @extends Phaser.GameObjects.Components.Mask
2928 * @extends Phaser.GameObjects.Components.Origin
@@ -43,7 +42,6 @@ var Shape = new Class({
4342 Mixins : [
4443 Components . AlphaSingle ,
4544 Components . BlendMode ,
46- Components . ComputedSize ,
4745 Components . Depth ,
4846 Components . GetBounds ,
4947 Components . Mask ,
@@ -172,28 +170,54 @@ var Shape = new Class({
172170 * Private internal value.
173171 * A Line used when parsing internal path data to avoid constant object re-creation.
174172 *
175- * @name Phaser.GameObjects.Curve #_tempLine
173+ * @name Phaser.GameObjects.Shape #_tempLine
176174 * @type {Phaser.Geom.Line }
177175 * @private
178176 * @since 3.13.0
179177 */
180178 this . _tempLine = new Line ( ) ;
181179
180+ /**
181+ * The native (un-scaled) width of this Game Object.
182+ *
183+ * Changing this value will not change the size that the Game Object is rendered in-game.
184+ * For that you need to either set the scale of the Game Object (`setScale`) or use
185+ * the `displayWidth` property.
186+ *
187+ * @name Phaser.GameObjects.Shape#width
188+ * @type {number }
189+ * @since 3.13.0
190+ */
191+ this . width = 0 ;
192+
193+ /**
194+ * The native (un-scaled) height of this Game Object.
195+ *
196+ * Changing this value will not change the size that the Game Object is rendered in-game.
197+ * For that you need to either set the scale of the Game Object (`setScale`) or use
198+ * the `displayHeight` property.
199+ *
200+ * @name Phaser.GameObjects.Shape#height
201+ * @type {number }
202+ * @since 3.0.0
203+ */
204+ this . height = 0 ;
205+
182206 this . initPipeline ( ) ;
183207 } ,
184208
185209 /**
186210 * Sets the fill color and alpha for this Shape.
187- *
211+ *
188212 * If you wish for the Shape to not be filled then call this method with no arguments, or just set `isFilled` to `false`.
189- *
213+ *
190214 * Note that some Shapes do not support fill colors, such as the Line shape.
191- *
215+ *
192216 * This call can be chained.
193217 *
194218 * @method Phaser.GameObjects.Shape#setFillStyle
195219 * @since 3.13.0
196- *
220+ *
197221 * @param {number } [color] - The color used to fill this shape. If not provided the Shape will not be filled.
198222 * @param {number } [alpha=1] - The alpha value used when filling this shape, if a fill color is given.
199223 *
@@ -219,16 +243,16 @@ var Shape = new Class({
219243
220244 /**
221245 * Sets the stroke color and alpha for this Shape.
222- *
246+ *
223247 * If you wish for the Shape to not be stroked then call this method with no arguments, or just set `isStroked` to `false`.
224- *
248+ *
225249 * Note that some Shapes do not support being stroked, such as the Iso Box shape.
226- *
250+ *
227251 * This call can be chained.
228252 *
229253 * @method Phaser.GameObjects.Shape#setStrokeStyle
230254 * @since 3.13.0
231- *
255+ *
232256 * @param {number } [lineWidth] - The width of line to stroke with. If not provided or undefined the Shape will not be stroked.
233257 * @param {number } [color] - The color used to stroke this shape. If not provided the Shape will not be stroked.
234258 * @param {number } [alpha=1] - The alpha value used when stroking this shape, if a stroke color is given.
@@ -257,12 +281,12 @@ var Shape = new Class({
257281 /**
258282 * Sets if this Shape path is closed during rendering when stroked.
259283 * Note that some Shapes are always closed when stroked (such as Ellipse shapes)
260- *
284+ *
261285 * This call can be chained.
262286 *
263287 * @method Phaser.GameObjects.Shape#setClosePath
264288 * @since 3.13.0
265- *
289+ *
266290 * @param {boolean } value - Set to `true` if the Shape should be closed when stroked, otherwise `false`.
267291 *
268292 * @return {this } This Game Object instance.
@@ -274,6 +298,34 @@ var Shape = new Class({
274298 return this ;
275299 } ,
276300
301+ /**
302+ * Sets the internal size of this Game Object, as used for frame or physics body creation.
303+ *
304+ * This will not change the size that the Game Object is rendered in-game.
305+ * For that you need to either set the scale of the Game Object (`setScale`) or call the
306+ * `setDisplaySize` method, which is the same thing as changing the scale but allows you
307+ * to do so by giving pixel values.
308+ *
309+ * If you have enabled this Game Object for input, changing the size will _not_ change the
310+ * size of the hit area. To do this you should adjust the `input.hitArea` object directly.
311+ *
312+ * @method Phaser.GameObjects.Shape#setSize
313+ * @private
314+ * @since 3.13.0
315+ *
316+ * @param {number } width - The width of this Game Object.
317+ * @param {number } height - The height of this Game Object.
318+ *
319+ * @return {this } This Game Object instance.
320+ */
321+ setSize : function ( width , height )
322+ {
323+ this . width = width ;
324+ this . height = height ;
325+
326+ return this ;
327+ } ,
328+
277329 /**
278330 * Internal destroy handler, called as part of the destroy process.
279331 *
@@ -287,6 +339,56 @@ var Shape = new Class({
287339 this . _tempLine = null ;
288340 this . pathData = [ ] ;
289341 this . pathIndexes = [ ] ;
342+ } ,
343+
344+ /**
345+ * The displayed width of this Game Object.
346+ *
347+ * This value takes into account the scale factor.
348+ *
349+ * Setting this value will adjust the Game Object's scale property.
350+ *
351+ * @name Phaser.GameObjects.Shape#displayWidth
352+ * @type {number }
353+ * @since 3.13.0
354+ */
355+ displayWidth : {
356+
357+ get : function ( )
358+ {
359+ return this . scaleX * this . width ;
360+ } ,
361+
362+ set : function ( value )
363+ {
364+ this . scaleX = value / this . width ;
365+ }
366+
367+ } ,
368+
369+ /**
370+ * The displayed height of this Game Object.
371+ *
372+ * This value takes into account the scale factor.
373+ *
374+ * Setting this value will adjust the Game Object's scale property.
375+ *
376+ * @name Phaser.GameObjects.Shape#displayHeight
377+ * @type {number }
378+ * @since 3.13.0
379+ */
380+ displayHeight : {
381+
382+ get : function ( )
383+ {
384+ return this . scaleY * this . height ;
385+ } ,
386+
387+ set : function ( value )
388+ {
389+ this . scaleY = value / this . height ;
390+ }
391+
290392 }
291393
292394} ) ;
0 commit comments