11var MATH_CONST = require ( '../math/const' ) ;
2- var WrapAngle = require ( '../math/angle/WrapDegrees' ) ;
2+ var WrapAngle = require ( '../math/angle/Wrap' ) ;
3+ var WrapAngleDegrees = require ( '../math/angle/WrapDegrees' ) ;
34
4- var _scaleX = 1 ;
5- var _scaleY = 1 ;
6-
7- // bitmask flag for GameObject.renderMask (used by Scale)
5+ // global bitmask flag for GameObject.renderMask (used by Scale)
86var _FLAG = 4 ; // 0100
97
108// Transform Component
119
1210var Transform = {
1311
12+ // "private" properties
13+ _scaleX : 1 ,
14+ _scaleY : 1 ,
15+ _rotation : 0 ,
16+
1417 x : 0 ,
1518 y : 0 ,
1619 z : 0 ,
1720
18- rotation : 0 ,
19-
2021 anchorX : 0 ,
2122 anchorY : 0 ,
2223
@@ -27,14 +28,14 @@ var Transform = {
2728
2829 get : function ( )
2930 {
30- return _scaleX ;
31+ return this . _scaleX ;
3132 } ,
3233
3334 set : function ( value )
3435 {
35- _scaleX = value ;
36+ this . _scaleX = value ;
3637
37- if ( _scaleX === 0 )
38+ if ( this . _scaleX === 0 )
3839 {
3940 this . renderFlags &= ~ _FLAG ;
4041 }
@@ -50,14 +51,14 @@ var Transform = {
5051
5152 get : function ( )
5253 {
53- return _scaleY ;
54+ return this . _scaleY ;
5455 } ,
5556
5657 set : function ( value )
5758 {
58- _scaleY = value ;
59+ this . _scaleY = value ;
5960
60- if ( _scaleY === 0 )
61+ if ( this . _scaleY === 0 )
6162 {
6263 this . renderFlags &= ~ _FLAG ;
6364 }
@@ -69,6 +70,34 @@ var Transform = {
6970
7071 } ,
7172
73+ angle : {
74+
75+ get : function ( )
76+ {
77+ return WrapAngleDegrees ( this . _rotation * MATH_CONST . RAD_TO_DEG ) ;
78+ } ,
79+
80+ set : function ( value )
81+ {
82+ // value is in degrees
83+ this . rotation = WrapAngleDegrees ( value ) * MATH_CONST . DEG_TO_RAD ;
84+ }
85+ } ,
86+
87+ rotation : {
88+
89+ get : function ( )
90+ {
91+ return this . _rotation ;
92+ } ,
93+
94+ set : function ( value )
95+ {
96+ // value is in radians
97+ this . _rotation = WrapAngle ( value ) ;
98+ }
99+ } ,
100+
72101 setPosition : function ( x , y )
73102 {
74103 if ( y === undefined ) { y = x ; }
@@ -79,6 +108,13 @@ var Transform = {
79108 return this ;
80109 } ,
81110
111+ setRotation : function ( radians )
112+ {
113+ this . rotation = radians ;
114+
115+ return this ;
116+ } ,
117+
82118 setScale : function ( x , y )
83119 {
84120 if ( x === undefined ) { x = 1 ; }
@@ -110,20 +146,6 @@ var Transform = {
110146 this . offsetY = y ;
111147
112148 return this ;
113- } ,
114-
115- angle : {
116-
117- get : function ( )
118- {
119- return WrapAngle ( this . rotation * MATH_CONST . RAD_TO_DEG ) ;
120- } ,
121-
122- set : function ( value )
123- {
124- // value is in degrees
125- this . rotation = WrapAngle ( value ) * MATH_CONST . DEG_TO_RAD ;
126- }
127149 }
128150
129151} ;
0 commit comments