misc
类型
misc utilities
索引
方法
clampf
限定浮点数的最大最小值。clamp01
限定浮点数的取值范围为 0 ~ 1 之间。lerp
Linear interpolation between 2 numbers, the ratio sets how much it is biased to each enddegreesToRadians
converts degrees to radiansradiansToDegrees
converts radians to degrees
Details
方法
clampf
限定浮点数的最大最小值。
数值大于 max_inclusive 则返回 max_inclusive。
数值小于 min_inclusive 则返回 min_inclusive。
否则返回自身。
meta | description |
---|---|
返回 | Number |
定义于 | cocos2d/core/utils/misc.js:148 |
参数列表
示例
var v1 = cc.misc.clampf(20, 0, 20); // 20;
var v2 = cc.misc.clampf(-1, 0, 20); // 0;
var v3 = cc.misc.clampf(10, 0, 20); // 10;
clamp01
限定浮点数的取值范围为 0 ~ 1 之间。
meta | description |
---|---|
返回 | Number |
定义于 | cocos2d/core/utils/misc.js:174 |
参数列表
value
Number
示例
var v1 = cc.misc.clamp01(20); // 1;
var v2 = cc.misc.clamp01(-1); // 0;
var v3 = cc.misc.clamp01(0.5); // 0.5;
lerp
Linear interpolation between 2 numbers, the ratio sets how much it is biased to each end
meta | description |
---|---|
返回 | Number |
定义于 | cocos2d/core/utils/misc.js:189 |
参数列表
示例
----
lerp
cc.misc.lerp(2,10,0.5)//returns 6
cc.misc.lerp(2,10,0.2)//returns 3.6
degreesToRadians
converts degrees to radians
meta | description |
---|---|
返回 | Number |
定义于 | cocos2d/core/utils/misc.js:202 |
参数列表
angle
Number
radiansToDegrees
converts radians to degrees
meta | description |
---|---|
返回 | Number |
定义于 | cocos2d/core/utils/misc.js:212 |
参数列表
angle
Number