cocos2d中生成随机数

<span style="background-color: rgb(0, 0, 153);">
</span>
<span style="background-color: rgb(204, 204, 204);">#include "<span style="font-family:Arial Black;">cocos2d</span>.h"</span>
<span style="background-color: rgb(204, 204, 204);">USING_NS_CC;//名称控件不可少</span>
<span style="background-color: rgb(204, 204, 204);">int MyRandom(int min, int max)
{
	struct tm*tm;
	time_t timP;
	if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
	{
		time(&timP);
	}
	else
	{
		struct timeval tv;

		gettimeofday(&tv, NULL);</span>
<span style="background-color: rgb(204, 204, 204);">		timP = tv.tv_sec;
	}
	tm = localtime(&timP);
	int Sencond = tm->tm_sec;
	return (((int)(CCRANDOM_0_1() * 1000) + Sencond) % (max-min) + min);

}</span>


你可能感兴趣的:(cocos2d中生成随机数)