misc Class

Module: cc

misc utilities

Index

Methods
  • clampf Clamp a value between from and to.
  • clamp01 Clamp a value between 0 and 1.
  • lerp Linear interpolation between 2 numbers, the ratio sets how much it is biased to each end
  • degreesToRadians converts degrees to radians
  • radiansToDegrees converts radians to degrees

Details

Methods

clampf

Clamp a value between from and to.

meta description
Returns Number
Defined in cocos2d/core/utils/misc.js:148
Parameters
Examples
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

Clamp a value between 0 and 1.

meta description
Returns Number
Defined in cocos2d/core/utils/misc.js:174
Parameters
Examples
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
Returns Number
Defined in cocos2d/core/utils/misc.js:189
Parameters
Examples
----
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
Returns Number
Defined in cocos2d/core/utils/misc.js:202
Parameters
radiansToDegrees

converts radians to degrees

meta description
Returns Number
Defined in cocos2d/core/utils/misc.js:212
Parameters

results matching ""

    No results matching ""