@@ -5,13 +5,14 @@ var Layer = new Class({
55
66 initialize :
77
8- function Layer ( )
8+ function Layer ( )
99 {
1010 this . children = [ ] ;
11+
1112 Array . prototype . push . apply ( this . children , arguments ) ;
1213 } ,
1314
14- add : function ( child )
15+ add : function ( child )
1516 {
1617 var children = this . children ;
1718 var index = children . indexOf ( child ) ;
@@ -20,103 +21,139 @@ var Layer = new Class({
2021 {
2122 children . push ( child ) ;
2223 }
24+
25+ return this ;
2326 } ,
2427
2528 addArray : function ( childrenArray )
2629 {
2730 var length = childrenArray . length ;
31+
2832 for ( var index = 0 ; index < length ; ++ index )
2933 {
3034 this . add ( childrenArray [ index ] ) ;
3135 }
36+
37+ return this ;
3238 } ,
3339
34- addX : function ( value ) {
40+ addX : function ( value )
41+ {
3542 var children = this . children ;
3643 var length = children . length ;
44+
3745 for ( var index = 0 ; index < length ; ++ index )
3846 {
3947 children [ index ] . x += value ;
4048 }
49+
50+ return this ;
4151 } ,
4252
43- addY : function ( value )
53+ addY : function ( value )
4454 {
4555 var children = this . children ;
4656 var length = children . length ;
4757 for ( var index = 0 ; index < length ; ++ index )
4858 {
4959 children [ index ] . y += value ;
5060 }
61+
62+ return this ;
5163 } ,
5264
53- addPosition : function ( x , y )
65+ addPosition : function ( x , y )
5466 {
5567 var children = this . children ;
5668 var length = children . length ;
69+
5770 for ( var index = 0 ; index < length ; ++ index )
5871 {
5972 children [ index ] . x += x ;
6073 children [ index ] . y += y ;
6174 }
75+
76+ return this ;
6277 } ,
6378
64- rotate : function ( value ) {
79+ rotate : function ( value )
80+ {
6581 var children = this . children ;
6682 var length = children . length ;
83+
6784 for ( var index = 0 ; index < length ; ++ index )
6885 {
6986 children [ index ] . rotation += value ;
7087 }
88+
89+ return this ;
7190 } ,
7291
73- setX : function ( value ) {
92+ setX : function ( value )
93+ {
7494 var children = this . children ;
7595 var length = children . length ;
96+
7697 for ( var index = 0 ; index < length ; ++ index )
7798 {
7899 children [ index ] . x = value ;
79100 }
101+
102+ return this ;
80103 } ,
81104
82- setY : function ( value )
105+ setY : function ( value )
83106 {
84107 var children = this . children ;
85108 var length = children . length ;
109+
86110 for ( var index = 0 ; index < length ; ++ index )
87111 {
88112 children [ index ] . y = value ;
89113 }
114+
115+ return this ;
90116 } ,
91117
92- setRotation : function ( value ) {
118+ setRotation : function ( value )
119+ {
93120 var children = this . children ;
94121 var length = children . length ;
122+
95123 for ( var index = 0 ; index < length ; ++ index )
96124 {
97125 children [ index ] . rotation = value ;
98126 }
127+
128+ return this ;
99129 } ,
100130
101- setVisible : function ( value ) {
131+ setVisible : function ( value )
132+ {
102133 var children = this . children ;
103134 var length = children . length ;
135+
104136 for ( var index = 0 ; index < length ; ++ index )
105137 {
106138 children [ index ] . visible = value ;
107- }
139+ }
140+
141+ return this ;
108142 } ,
109143
110144 toggleVisible : function ( )
111145 {
112146 var children = this . children ;
113147 var length = children . length ;
148+
114149 for ( var index = 0 ; index < length ; ++ index )
115150 {
116151 children [ index ] . visible = ! children [ index ] . visible ;
117- }
152+ }
153+
154+ return this ;
118155 }
119156
120157} ) ;
121158
122- module . exports = Layer ;
159+ module . exports = Layer ;
0 commit comments