Cocos Creator API

1.0.0

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

Size

Module: 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.

Properties

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

Methods

Size
(
  • width
  • height
)
Size

name type description
width Number
height Number

returns:

type: Size

clone ( ) Size

TODO

returns:

type: Size

examples:

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

equals
(
  • other
)
Boolean

TODO

name type description
other Size

returns:

type: Boolean

examples:

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

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

TODO

name type description
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.

returns:

type: Size

examples:

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

returns:

type: String

examples:

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.

name type description
w Number | Size

width or a size object

h Number

height

returns:

type: Size

examples:

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.

name type description
size1 Size
size2 Size

returns:

type: Boolean

examples:

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