Skip to content

Commit

Permalink
refactor(gameobjects): tidy Circle
Browse files Browse the repository at this point in the history
  • Loading branch information
remarkablemark committed Apr 23, 2024
1 parent 7725981 commit f4273f0
Showing 1 changed file with 7 additions and 15 deletions.
22 changes: 7 additions & 15 deletions src/gameobjects/Circle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,21 @@ import Phaser from 'phaser';
import { _ } from '../constants';

const CIRCLE_CONTAINER = 'CIRCLE_CONTAINER';
const x = 0;
const y = 0;
const radius = 16;
const startAngle = 0;
const endAngle = 360;
const anticlockwise = false;

export class Circle extends Phaser.GameObjects.Arc {
color: number;

constructor(scene: Phaser.Scene, color: number) {
const x = 0;
const y = 0;
const radius = 16;
const startAngle = 0;
const endAngle = 360;
const anticlockwise = false;

super(scene, x, y, radius, startAngle, endAngle, anticlockwise, color);
scene.add.existing(this);

this.color = color;

const hasColor = color !== _;

this.setOrigin(0.5)
Expand All @@ -29,13 +27,7 @@ export class Circle extends Phaser.GameObjects.Arc {
.setActive(hasColor)
.setVisible(hasColor);

let container = Circle.getContainer(scene);

if (!container) {
container = Circle.setContainer(scene);
}

container.add(this);
Circle.getContainer(scene).add(this);
}

/**
Expand Down

0 comments on commit f4273f0

Please sign in to comment.