import 'p2' ; import 'pixi' ; import 'phaser' ; import { Atlases } from '../Data' ; export default class LanguageButton extends Phaser . Group { protected languageBtn : Phaser . Sprite ; protected maxWidth : number ; protected maxHeight : number ; constructor ( game , language , callback , callbackContext ) { super ( game ) ; let background = this . game . add . image ( 0 , 0 , Atlases . Interface , 'flag_background' ) ; background . anchor . set ( 0.5 ) ; this . add ( background ) ; this . languageBtn = this . game . add . sprite ( 0 , 1 , Atlases . Interface , 'flag_' + language ) ; this . languageBtn . anchor . set ( 0.5 ) ; this . languageBtn . inputEnabled = true ; this . languageBtn . input . useHandCursor = true ; if ( callback && callbackContext ) { this . languageBtn . events . onInputUp . add ( callback , callbackContext ) ; } this . add ( this . languageBtn ) ; this . game . add . existing ( this ) ; } public updateLanguage ( language ) { this . languageBtn . loadTexture ( Atlases . Interface , 'flag_' + language ) ; } param destroyChildren public destroy ( destroyChildren ? ) { super . destroy ( destroyChildren ) ; } }