c++ random
srand(time(0));
random(0, 1000) / 1000.0
cocos2dx 中截屏方法
string fileName = "capture.png";
utils::captureScreen([=](bool success,string outFileName){
if (success)
{
CCLOG("Suceess\n");
CCLOG("----------%s------------",outFileName);
Sprite*sp = Sprite::create(outFileName);
sp->setPosition(Point(vSize.width / 2,vSize.height/2));
sp->setScale(0.5);
this->addChild(sp);
}
else
{
CCLOG("sorry,you are field\n");
}
}, fileName);
截屏函数的默认图片保存位置为:
FileUtils::getInstance()->getWritablePath().c_str()
要使用UI借口,请包含如下头文件:
#include "cocos2d.h"
#include "ui/CocosGUI.h"
USING_NS_CC;
using namespace ui;
USING_NS_CC;
using namespace std;