I’m been searching and it is not quite simple for me how to implement it
it seems I can’t rely if I want to build my game for android or win32 other than ios.
can somebody post how can I get random int(not float) between 1 to 60?
any tips are welcome, you don’t have to post the whole solution
thanks
2 Likes
hzlov
#2
there is cocos2d::RandomHelper::random_int(1, 60);
5 Likes
worked great, thanks for sharing your knoledge
hey what about using this statement : int x = arc4random() % 60 + 1;
which one is better…
import cstdlib
and then use rand()%60 +1 to give you numbers for the range 1 to 60
IzzyJM
#8
does cocos2d::RandomHelper::random_int(1, 60); suffer from modulo bias ?
If you want to generate random numbers, I think there are better ways: https://zuttobenkyou.wordpress.com/2012/10/18/generating-random-numbers-without-modulo-bias/
You can always look at the source code of the RandomHelper
class and check
1 Like