import { IGraphicsConstructor } from '../interfaces/graphics.interface' ; export class Ray extends Phaser . GameObjects . Graphics { private direction : Phaser . Math . Vector2 ; private movingSpeed : number ; private rayCircle : Phaser . Geom . Circle ; constructor ( aParams ) { super ( aParams . scene , aParams . options ) ; this . initVariables ( aParams . direction ) ; this . initGraphics ( aParams . options ) ; this . scene . add . existing ( this ) ; } private initVariables ( direction ) { this . direction = direction . normalize ( ) ; this . movingSpeed = 2 ; } private initGraphics ( aParams ) { this . setPosition ( aParams . x , aParams . y ) ; this . rayCircle = new Phaser . Geom . Circle ( this . direction . x , this . direction . y , 4 ) ; this . fillCircleShape ( this . rayCircle ) ; } update ( ) { this . x += this . direction . x * this . movingSpeed ; this . y += this . direction . y * this . movingSpeed ; } }