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