Path: blob/main/public/games/files/space-invaders/assets/javascript/module/HUD.js
1520 views
/**1* Created by stryker on 2014.03.05..2*/3define(function(){4//Private variables5var _game = null,6_health = null,7_healthText = null,8_lives = null,9_livesText = null,10_score = null,11_scoreText = null,12_stateText = null;1314return{15init: function(game){16_game = game;17},18preload: function(){19//_game.load.image('ship', 'assets/img/player.png');20},21createStat: function(score,health,lives){22_score = score;23_scoreText = _game.add.text(10, 10, "Score: " + score, { fontSize: '34px', fill: '#fff' });24_health = health;25_healthText = _game.add.text(10, 50, "Health: " + health, { fontSize: '34px', fill: '#fff' });26_lives = lives;27_livesText = _game.add.text(10, 90, "Lives: " + lives, { fontSize: '34px', fill: '#fff' });2829//_stateText.visible = false;30},31updateHealthText: function(health){32_healthText.text = "Health: "+health;33},34updateLivesText: function(lives){35_livesText.text = "Lives: "+lives;36},37updateScoreText: function(score){38_scoreText.text = "Score: "+(_score+=score);39},40createTitle: function(title){41_stateText = _game.add.text(_game.world.centerX,_game.world.centerY,42title,{font: '84px Arial',fill: '#fff'})43_stateText.anchor.setTo(0.5,0.5);44}45}46});4748