加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

cocos2d中生成随机数

发布时间:2020-12-14 16:35:30 所属栏目:百科 来源:网络整理
导读:span style="background-color: rgb(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);"USING_NS_CC;//名称控件不可少/sp
<span style="background-color: rgb(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);">USING_NS_CC;//名称控件不可少</span>
<span style="background-color: rgb(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);">		timP = tv.tv_sec;
	}
	tm = localtime(&timP);
	int Sencond = tm->tm_sec;
	return (((int)(CCRANDOM_0_1() * 1000) + Sencond) % (max-min) + min);

}</span>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读