Skip to main content
Version: Phaser v3.88.2

Ellipse

The Ellipse Shape is a Game Object that can be added to a Scene, Group or Container. You can

treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling

it for input or physics. It provides a quick and easy way for you to render this shape in your

game without using a texture, while still taking advantage of being fully batched in WebGL.

This shape supports both fill and stroke colors.

When it renders it displays an ellipse shape. You can control the width and height of the ellipse.

If the width and height match it will render as a circle. If the width is less than the height,

it will look more like an egg shape.

The Ellipse shape also has a smoothness property and corresponding setSmoothness method.

This allows you to control how smooth the shape renders in WebGL, by controlling the number of iterations

that take place during construction. Increase and decrease the default value for smoother, or more

jagged, shapes.

Constructor

new Ellipse(scene, [x], [y], [width], [height], [fillColor], [fillAlpha])

Parameters

nametypeoptionaldefaultdescription
scenePhaser.SceneNoThe Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time.
xnumberYes0The horizontal position of this Game Object in the world.
ynumberYes0The vertical position of this Game Object in the world.
widthnumberYes128The width of the ellipse. An ellipse with equal width and height renders as a circle.
heightnumberYes128The height of the ellipse. An ellipse with equal width and height renders as a circle.
fillColornumberYesThe color the ellipse will be filled with, i.e. 0xff0000 for red.
fillAlphanumberYesThe alpha the ellipse will be filled with. You can also set the alpha of the overall Shape using its alpha property.

Scope: static

Extends

Phaser.GameObjects.Shape

Source: src/gameobjects/shape/ellipse/Ellipse.js#L13
Since: 3.13.0

Inherited Members

From Phaser.GameObjects.Components.AlphaSingle:

From Phaser.GameObjects.Components.BlendMode:

From Phaser.GameObjects.Components.Depth:

From Phaser.GameObjects.Components.Mask:

From Phaser.GameObjects.Components.Origin:

From Phaser.GameObjects.Components.Pipeline:

From Phaser.GameObjects.Components.PostPipeline:

From Phaser.GameObjects.Components.ScrollFactor:

From Phaser.GameObjects.Components.Transform:

From Phaser.GameObjects.Components.Visible:

From Phaser.GameObjects.GameObject:

From Phaser.GameObjects.Shape:


Public Members

smoothness

smoothness: number

Description:

The smoothness of the ellipse. The number of points used when rendering it.

Increase this value for a smoother ellipse, at the cost of more polygons being rendered.

Source: src/gameobjects/shape/ellipse/Ellipse.js#L89
Since: 3.13.0


Inherited Methods

From Phaser.Events.EventEmitter:

From Phaser.GameObjects.Components.AlphaSingle:

From Phaser.GameObjects.Components.BlendMode:

From Phaser.GameObjects.Components.Depth:

From Phaser.GameObjects.Components.GetBounds:

From Phaser.GameObjects.Components.Mask:

From Phaser.GameObjects.Components.Origin:

From Phaser.GameObjects.Components.Pipeline:

From Phaser.GameObjects.Components.PostPipeline:

From Phaser.GameObjects.Components.ScrollFactor:

From Phaser.GameObjects.Components.Transform:

From Phaser.GameObjects.Components.Visible:

From Phaser.GameObjects.GameObject:

From Phaser.GameObjects.Shape:


Public Methods

setSize

<instance> setSize(width, height)

Description:

Sets the size of the ellipse by changing the underlying geometry data, rather than scaling the object.

This call can be chained.

Parameters:

nametypeoptionaldescription
widthnumberNoThe width of the ellipse.
heightnumberNoThe height of the ellipse.

Overrides: Phaser.GameObjects.Shape#setSize

Returns: Phaser.GameObjects.Ellipse - This Game Object instance.

Source: src/gameobjects/shape/ellipse/Ellipse.js#L114
Since: 3.13.0


setSmoothness

<instance> setSmoothness(value)

Description:

Sets the smoothness of the ellipse. The number of points used when rendering it.

Increase this value for a smoother ellipse, at the cost of more polygons being rendered.

This call can be chained.

Parameters:

nametypeoptionaldescription
valuenumberNoThe value to set the smoothness to.

Returns: Phaser.GameObjects.Ellipse - This Game Object instance.

Source: src/gameobjects/shape/ellipse/Ellipse.js#L138
Since: 3.13.0