Browse Source

✨ Add setter for Object2D's position

Pedro Schneider 3 years ago
parent
commit
7337418ace
1 changed files with 12 additions and 0 deletions
  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.