Ellipse Contains Point
Demonstrates how to check if a specific coordinate, such as the mouse pointer, is located inside the area of an ellipse.
800 × 600
class Example extends Phaser.Scene
{
create ()
{
const graphics = this.add.graphics({ lineStyle: { width: 2, color: 0x00aaaa } });
const ellipse = new Phaser.Geom.Ellipse(400, 300, 400, 250);
graphics.strokeEllipseShape(ellipse);
this.input.on('pointermove', pointer =>
{
graphics.clear();
if (ellipse.contains(pointer.x, pointer.y))
{
graphics.lineStyle(2, 0xaa0000);
}
else
{
graphics.lineStyle(2, 0x00aaaa);
}
graphics.strokeEllipseShape(ellipse);
});
}
}
const config = {
scale: { mode: Phaser.Scale.FIT },
width: 800,
height: 600,
type: Phaser.AUTO,
parent: 'game-container',
scene: Example
};
const game = new Phaser.Game(config);