Cocos Creator API

1.3.0

Cocos Creator is a highly customizable game development tool that utilizes the power of cocos2d-x.

Size

: cc

cc.Size is the class for size object,
please do not use its constructor to create sizes,
use size alias function instead.
It will be deprecated soon, please use cc.Vec2 instead.

ZERO Size static

return a Size object with width = 0 and height = 0.

There are no properties that match your current filter settings. You can change your filter settings in the index section on this page. index

Size
(
  • width
  • height
)
Size

width Number
height Number

:

: Size

clone ( ) Size

TODO

:

: Size

:

var a = new cc.size(10, 10);
a.clone();// return Size {width: 0, height: 0};

equals
(
  • other
)
Boolean

TODO

other Size

:

:

var a = new cc.size(10, 10);
a.equals(new cc.size(10, 10));// return true;

lerp
(
  • to
  • ratio
  • [out ]
)
Size

TODO

to Rect

!#en Constructor of cc.Rect class. see cc.rect for convenience method. !#zh cc.Rect类的构造函数。可以通过 cc.rect 简便方法进行创建。

  • x Number optional , default: 0
  • y Number optional , default: 0
  • w Number optional , default: 0
  • h Number optional , default: 0
ratio Number

the interpolation coefficient.

out optional Size

optional, the receiving vector.

:

: Size

:

var a = new cc.size(10, 10);
var b = new cc.rect(50, 50, 100, 100);
update (dt) {
   // method 1;
   var c = a.lerp(b, dt * 0.1);
   // method 2;
   a.lerp(b, dt * 0.1, c);
}

toString ( ) String

TODO

:

: String

:

var a = new cc.size(10, 10);
a.toString();// return "(10.00, 10.00)";

size
(
  • w
  • h
)
Size

Helper function that creates a cc.Size.
Please use cc.p or cc.v2 instead, it will soon replace cc.Size.

w Number | Size

width or a size object

h Number

height

:

: Size

:

var size1 = cc.size();
var size2 = cc.size(100,100);
var size3 = cc.size(size2);
var size4 = cc.size({width: 100, height: 100});

sizeEqualToSize
(
  • size1
  • size2
)
Boolean

Check whether a point's value equals to another.

size1 Size
size2 Size

:

:

var a = new cc.size(10, 10);
var b = new cc.size(10, 10);
cc.sizeEqualToSize(a, b);// return true;
var b = new cc.size(5, 10);
cc.sizeEqualToSize(a, b);// return false;

There are no methods that match your current filter settings. You can change your filter settings in the index section on this page. index