Pārlūkot izejas kodu

✨ Add setter for Object2D's position

Pedro Schneider 3 gadi atpakaļ
vecāks
revīzija
7337418ace
1 mainītis faili ar 12 papildinājumiem un 0 dzēšanām
  1. 12 0
      pandora/game_objects/2d_objects/Object2D.js

+ 12 - 0
pandora/game_objects/2d_objects/Object2D.js

@@ -50,6 +50,18 @@ class Object2D extends GameObject
         this.visible = true; // Is this Object2D visible at the moment?
     }
 
+    /**
+     * Sets this Object2D's position.
+     * 
+     * @param {number} x    new position on the x axis for this Object2D. 
+     * @param {number} y    new positoin on the y axis for this Object2D.
+     */
+    setPosition(x, y)
+    {
+        this.position.x = x;
+        this.position.y = y;
+    }
+
     /**
      * Sets the visibility flag of this Object2D and all of its children
      * that have a visibility flag to true.