Browse Source

✨ Add Input UIObject

Pedro Schneider 3 năm trước cách đây
mục cha
commit
d566f4f895
2 tập tin đã thay đổi với 25 bổ sung0 xóa
  1. 1 0
      index.html
  2. 24 0
      pandora/game_objects/ui_objects/Input.js

+ 1 - 0
index.html

@@ -40,6 +40,7 @@
       <script type="text/javascript" src="pandora/game_objects/ui_objects/Select.js"></script>
       <script type="text/javascript" src="pandora/game_objects/ui_objects/Radio.js"></script>
       <script type="text/javascript" src="pandora/game_objects/ui_objects/ColorPicker.js"></script>
+      <script type="text/javascript" src="pandora/game_objects/ui_objects/Input.js"></script>
 
     <!-- Handlers -->
     <script type="text/javascript" src="pandora/handlers/GameHandler.js"></script>

+ 24 - 0
pandora/game_objects/ui_objects/Input.js

@@ -0,0 +1,24 @@
+class Input extends UIObject
+{
+    constructor(name, value = "", type = "text")
+    {
+        super(name);
+
+        this.P5Element = createInput(value, type);
+        this.setPosition(0, 0);
+        this.setStyle(DEFAULT_STYLE);
+
+        this.connectCallbacks();
+        this.P5Element.input(this.onInput);
+    }
+
+    _onInput()
+    {
+
+    }
+
+    onInput()
+    {
+        this.pandoraObject._onInput();
+    }
+}