Skip to content
This repository has been archived by the owner on Feb 12, 2023. It is now read-only.

Commit

Permalink
[Engine]: add positions methods to the text
Browse files Browse the repository at this point in the history
  • Loading branch information
201flaviosilva committed Mar 7, 2022
1 parent 3d7d3e4 commit ec99b02
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/GameObjects/Text/Text.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,22 @@ export default class Text extends GameObject {
get x() { return this._x - this.width * this.origin.x; } // Get the position X relative to the origin
get y() { return this._y - this.height * this.origin.y; } // Get the position Y relative to the origin

// Get positions based on the origin
getTop() { return this.y; }
getBottom() { return this.y + this.height; }
getLeft() { return this.x; }
getRight() { return this.x + this.width; }
getCenterX() { return this.x + this.width / 2; }
getCenterY() { return this.y + this.height / 2; }

// Get Real Positions
getRealTop() { return this._y; }
getRealBottom() { return this._y + this.height; }
getRealLeft() { return this._x; }
getRealRight() { return this._x + this.width; }
getRealCenterX() { return this._x + this.width / 2; }
getRealCenterY() { return this._y + this.height / 2; }

getOptions() {
const opt = {
font: {
Expand Down

0 comments on commit ec99b02

Please sign in to comment.