HUD.js 872 B

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