Cocos Creator API categorization

I am new to Cocos platform and I finding it very difficult to adapt with the “API”!!
I found that it’s not organised properly. I am trying to learn with the tutorial on the Cocos 2d-x site where a function cc.random0To1() and cc.randomMinus1To1() are used which I couldn’t find in the documentation!!!:cold_sweat:

Please help me with the above functions and the my program cocos creator 1.3.2 doesn’t recognize these functions.

It’s there, just have to look for it…

http://cocos2d-x.org/docs/api-ref/js/v3x/symbols/cc.html#.random0To1

Ohh. I was looking in the Cocos Creator API. Now I realized that Cocos Creator has inbuilt Cocos2d-js and I can even use that API. But I need to figure out why Cocos Creator was not able to compile the code… Thanks by the way. Could you suggest any way to get the whole documentation offline?

Could you help me out? I can’t find the above-mentioned function by typing in the search bar in the API link.
I can find the function with your link but for searching it directly at API section by going to the link provided in cocos2d-x site I can’t find this function. Thanks in advance!!!

If function is not here: http://cocos2d-x.org/docs/api-ref/creator/v1.3/ then does not exist for Creator.
You have to find a different way to do whatever you want to do.

If you need random numbers try using standard JS Math object: http://www.w3schools.com/js/js_math.asp

1 Like

Hello,

I have just had the same issue trying to find documentation for Random0to1().

It seems:

  1. Go to this link: http://www.cocos2d-x.org/docs/api-ref/js/v3x/
  2. Click on ‘cc’ on the left
  3. You’ll find an entry for cc.random0to1() on the page on the right (in the Method Summary section)

Hope that helps,
Tem

1 Like

Hi @bhargav13,

For my games I use the folowing:

this.randexmaple1 = Math.floor(Math.random() * 7) + 1;
this.randexample2 = Math.floor(Math.random()*(411+185)-185);

var randexample3 = Math.floor(Math.random()*(300+305)-305);

Go here for further explanation:
https://www.w3schools.com/js/js_random.asp

God Bless…

Sincerely,

Sunday

1 Like