Ver código fonte

✨ Add new Label UI object

Pedro Schneider 3 anos atrás
pai
commit
682c510ad4
2 arquivos alterados com 21 adições e 0 exclusões
  1. 1 0
      index.html
  2. 20 0
      pandora/game_objects/ui_objects/Label.js

+ 1 - 0
index.html

@@ -32,6 +32,7 @@
     <!-- UI Game Objects -->
     <script type="text/javascript" src="pandora/game_objects/ui_objects/UIObject.js"></script>
     <script type="text/javascript" src="pandora/game_objects/ui_objects/Button.js"></script>
+    <script type="text/javascript" src="pandora/game_objects/ui_objects/Label.js"></script>
 
     <!-- Handlers -->
     <script type="text/javascript" src="pandora/handlers/GameHandler.js"></script>

+ 20 - 0
pandora/game_objects/ui_objects/Label.js

@@ -0,0 +1,20 @@
+class Label extends UIObject
+{
+    constructor(name, text = "Label")
+    {
+        super(name);
+        this.text = text;
+        this.P5Element = createDiv(text);
+        this.P5Element.position(0, 0);
+
+        this.setStyle(DEFAULT_STYLE);
+
+        this.connectCallbacks();
+    }
+
+    setText(t)
+    {
+        this.P5Element.html(t);
+        this.text = t;
+    }
+}