Circle Offset Point
Demonstrates how to shift a circle's position by the coordinates of a point or vector using the OffsetPoint method.
800 × 600
class Example extends Phaser.Scene
{
create ()
{
const circle = new Phaser.Geom.Circle(50, 300, 50);
const graphics = this.add.graphics({ lineStyle: { color: 0x00ff00 } });
graphics.strokeCircleShape(circle);
const point = new Phaser.Math.Vector2(Math.cos(Math.PI / 4) * 100, Math.sin(Math.PI / 4) * 100);
for (let i = 0; i < 10; i++)
{
Phaser.Geom.Circle.OffsetPoint(circle, point);
graphics.strokeCircleShape(circle);
point.y *= -1;
}
}
}
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);