HUD.js 900 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /* global SpaceGame */
  2. 'atomic component';
  3. exports.component = function(self) {
  4. var game = Atomic.game;
  5. var view = game.uiView;
  6. var UI = Atomic.UI;
  7. var UIButton = Atomic.UIButton;
  8. var UITextField = Atomic.UITextField;
  9. var UILayout = Atomic.UILayout;
  10. var layout = new Atomic.UIWidget();
  11. layout.load("UI/Hud.ui.txt");
  12. layout.setSize(game.graphics.width, game.graphics.height);
  13. view.addChild(layout);
  14. SpaceGame.viewport.rect = layout.getWidget("viewport").rect;
  15. self.cleanup = function() {
  16. view.removeChild(layout);
  17. };
  18. var scoretext = layout.getWidget("scoretext");
  19. //UI.debugShowSettingsWindow(view);
  20. self.updateScore = function(value) {
  21. scoretext.text = "Score: " + value;
  22. };
  23. self.updateHealth = function(value) {
  24. //healthText.text = "Health: " + value;
  25. };
  26. self.updateGameText = function(text) {
  27. //gameText.text = text;
  28. };
  29. };