Skip to content

Commit fa85f43

Browse files
committed
displayOriginX and displayOriginY are now getters / setters that will protect the actual values
1 parent 583a645 commit fa85f43

File tree

1 file changed

+32
-5
lines changed

1 file changed

+32
-5
lines changed

v3/src/gameobjects/components/Origin.js

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,38 @@ var Origin = {
88
originY: 0.5,
99

1010
// READ ONLY
11-
displayOriginX: 0,
12-
displayOriginY: 0,
11+
_displayOriginX: 0,
12+
_displayOriginY: 0,
13+
14+
displayOriginX: {
15+
16+
get: function ()
17+
{
18+
return this._displayOriginX;
19+
},
20+
21+
set: function (value)
22+
{
23+
this._displayOriginX = value;
24+
this.originX = (value === 0) ? 0 : this.width / value;
25+
}
26+
27+
},
28+
29+
displayOriginY: {
30+
31+
get: function ()
32+
{
33+
return this._displayOriginY;
34+
},
35+
36+
set: function (value)
37+
{
38+
this._displayOriginY = value;
39+
this.originY = (value === 0) ? 0 : this.height / value;
40+
}
41+
42+
},
1343

1444
setOrigin: function (x, y)
1545
{
@@ -30,9 +60,6 @@ var Origin = {
3060
this.displayOriginX = x;
3161
this.displayOriginY = y;
3262

33-
this.originX = (x === 0) ? 0 : this.width / x;
34-
this.originY = (y === 0) ? 0 : this.height / y;
35-
3663
return this;
3764
},
3865

0 commit comments

Comments
 (0)