import { IBlockConstructor } from '../interfaces/block.interface' ; export class Block extends Phaser . GameObjects . Sprite { private blockType : number ; private isDying : boolean ; constructor ( aParams ) { super ( aParams . scene , aParams . x , aParams . y , aParams . texture , aParams . type ) ; this . blockType = aParams . type ; this . isDying = false ; this . initSprite ( ) ; this . scene . add . existing ( this ) ; } update ( ) { if ( this . isDying ) { this . alpha -= 0.02 ; if ( this . alpha === 0 ) { this . isDying = false ; this . setType ( 0 ) ; this . setAlpha ( 1 ) ; } } } private initSprite ( ) { this . setFrame ( this . blockType ) ; this . setOrigin ( 0 , 0 ) ; } public getType ( ) { return this . blockType ; } public setType ( id ) { this . blockType = id ; this . setFrame ( this . blockType ) ; } public activateDead ( ) { this . isDying = true ; } public getDead ( ) { return this . isDying ; } }