Skip to content

Commit b21fa19

Browse files
committed
Removed anchor property from Transform, and added in the new Origin component.
1 parent 06a0a61 commit b21fa19

5 files changed

Lines changed: 41 additions & 26 deletions

File tree

v3/src/checksum.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
var CHECKSUM = {
2-
build: 'e143e9e0-fe97-11e6-b242-774fc1dcf72c'
2+
build: '923bfa40-feec-11e6-8134-ffb6fa7d3604'
33
};
44
module.exports = CHECKSUM;

v3/src/components/Origin.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Origin Component
2+
// Values are given in pixels, not percent
3+
4+
var Origin = {
5+
6+
originX: 0,
7+
originY: 0,
8+
9+
setOrigin: function (x, y)
10+
{
11+
if (x === undefined) { x = 0; }
12+
if (y === undefined) { y = x; }
13+
14+
this.originX = x;
15+
this.originY = y;
16+
17+
return this;
18+
},
19+
20+
setOriginToCenter: function ()
21+
{
22+
this.originX = this.frame.centerX;
23+
this.originY = this.frame.centerY;
24+
}
25+
26+
};
27+
28+
module.exports = Origin;

v3/src/components/Texture.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,18 @@ var Texture = {
2121
else
2222
{
2323
this.renderFlags |= _FLAG;
24+
25+
if (this.hasOwnProperty('originX'))
26+
{
27+
// Default origin to the center
28+
var w = Math.floor(this.frame.realWidth / 2);
29+
var h = Math.floor(this.frame.realHeight / 2);
30+
31+
this.setOrigin(w, h);
32+
}
2433
}
34+
35+
return this;
2536
}
2637

2738
};

v3/src/components/Transform.js

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@ var Transform = {
1818
y: 0,
1919
z: 0,
2020

21-
anchorX: 0,
22-
anchorY: 0,
23-
2421
scaleX: {
2522

2623
get: function ()
@@ -120,28 +117,6 @@ var Transform = {
120117
this.scaleX = x;
121118
this.scaleY = y;
122119

123-
return this;
124-
},
125-
126-
setAnchor: function (x, y)
127-
{
128-
if (x === undefined) { x = 0; }
129-
if (y === undefined) { y = x; }
130-
131-
this.anchorX = x;
132-
this.anchorY = y;
133-
134-
return this;
135-
},
136-
137-
setOffset: function (x, y)
138-
{
139-
if (x === undefined) { x = 0; }
140-
if (y === undefined) { y = x; }
141-
142-
this.offsetX = x;
143-
this.offsetY = y;
144-
145120
return this;
146121
}
147122

v3/src/components/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ module.exports = {
66
Color: require('./Color'),
77
Data: require('./Data'),
88
GetBounds: require('./GetBounds'),
9+
Origin: require('./Origin'),
910
ScaleMode: require('./ScaleMode'),
1011
Size: require('./Size'),
1112
Texture: require('./Texture'),

0 commit comments

Comments
 (0)