@@ -35,6 +35,16 @@ cc.Point = function (_x, _y) {
3535 this . y = _y || 0 ;
3636} ;
3737
38+ /**
39+ * Helper macro that creates a cc.Point.
40+ * @param {Number } x
41+ * @param {Number } y
42+ * @return { }
43+ */
44+ cc . p = function ( x , y ) {
45+ return new cc . Point ( x , y ) ;
46+ } ;
47+
3848/**
3949 * @function
4050 * @param {cc.Point } point1
@@ -81,29 +91,29 @@ cc.Rect = function (x1, y1, width1, height1) {
8191 switch ( arguments . length ) {
8292 case 0 :
8393 this . origin = cc . p ( 0 , 0 ) ;
84- this . size = new cc . Size ( 0 , 0 ) ;
94+ this . size = cc . size ( 0 , 0 ) ;
8595 break ;
8696 case 1 :
8797 var oldRect = x1 ;
8898 if ( ! oldRect ) {
8999 this . origin = cc . p ( 0 , 0 ) ;
90- this . size = new cc . Size ( 0 , 0 ) ;
100+ this . size = cc . size ( 0 , 0 ) ;
91101 } else {
92102 if ( oldRect instanceof cc . Rect ) {
93103 this . origin = cc . p ( oldRect . origin . x , oldRect . origin . y ) ;
94- this . size = new cc . Size ( oldRect . size . width , oldRect . size . height ) ;
104+ this . size = cc . size ( oldRect . size . width , oldRect . size . height ) ;
95105 } else {
96106 throw "unknown argument type" ;
97107 }
98108 }
99109 break ;
100110 case 2 :
101111 this . origin = x1 ? cc . p ( x1 . x , x1 . y ) : cc . p ( 0 , 0 ) ;
102- this . size = y1 ? new cc . Size ( y1 . width , y1 . height ) : new cc . Size ( 0 , 0 ) ;
112+ this . size = y1 ? cc . size ( y1 . width , y1 . height ) : cc . size ( 0 , 0 ) ;
103113 break ;
104114 case 4 :
105115 this . origin = cc . p ( x1 || 0 , y1 || 0 ) ;
106- this . size = new cc . Size ( width1 || 0 , height1 || 0 ) ;
116+ this . size = cc . size ( width1 || 0 , height1 || 0 ) ;
107117 break ;
108118 default :
109119 throw "unknown argument type" ;
@@ -250,7 +260,7 @@ cc.Rect.CCRectOverlapsRect = function (rectA, rectB) {
250260 * Constructor
251261 */
252262cc . Rect . CCRectUnion = function ( rectA , rectB ) {
253- var rect = new cc . Rect ( 0 , 0 , 0 , 0 ) ;
263+ var rect = cc . rect ( 0 , 0 , 0 , 0 ) ;
254264 rect . origin . x = Math . min ( rectA . origin . x , rectB . origin . x ) ;
255265 rect . origin . y = Math . min ( rectA . origin . y , rectB . origin . y ) ;
256266 rect . size . width = Math . max ( rectA . origin . x + rectA . size . width , rectB . origin . x + rectB . size . width ) - rect . origin . x ;
@@ -267,7 +277,7 @@ cc.Rect.CCRectUnion = function (rectA, rectB) {
267277 * Constructor
268278 */
269279cc . Rect . CCRectIntersection = function ( rectA , rectB ) {
270- var intersection = new cc . Rect (
280+ var intersection = cc . rect (
271281 Math . max ( cc . Rect . CCRectGetMinX ( rectA ) , cc . Rect . CCRectGetMinX ( rectB ) ) ,
272282 Math . max ( cc . Rect . CCRectGetMinY ( rectA ) , cc . Rect . CCRectGetMinY ( rectB ) ) ,
273283 0 , 0 ) ;
@@ -299,8 +309,16 @@ cc.SizeMake = function (width, height) {
299309 return new cc . Size ( width , height ) ;
300310} ;
301311
302- // backward compatible
303- cc . size = cc . SizeMake ;
312+ /**
313+ * @function
314+ * @param {Number } width
315+ * @param {Number } height
316+ * @return {Number, Number }
317+ * Constructor
318+ */
319+ cc . size = function ( w , h ) {
320+ return new cc . Size ( w , h ) ;
321+ }
304322
305323/**
306324 * @function
@@ -329,22 +347,22 @@ cc.PointZero = function () {
329347} ;
330348
331349/**
332- * The "zero" size -- equivalent to cc.SizeMake (0, 0).
350+ * The "zero" size -- equivalent to cc.size (0, 0).
333351 * @function
334352 * @return {cc.Size }
335353 * Constructor
336354 */
337355cc . SizeZero = function ( ) {
338- return new cc . Size ( 0 , 0 )
356+ return cc . size ( 0 , 0 )
339357} ;
340358
341359/**
342- * The "zero" rectangle -- equivalent to cc.RectMake (0, 0, 0, 0).
360+ * The "zero" rectangle -- equivalent to cc.rect (0, 0, 0, 0).
343361 * @function
344362 * @return {cc.Rect }
345363 * Constructor
346364 */
347365cc . RectZero = function ( ) {
348- return new cc . Rect ( 0 , 0 , 0 , 0 )
366+ return cc . rect ( 0 , 0 , 0 , 0 )
349367} ;
350368
0 commit comments