0

スクリーンショットを保存するためにこのコードを使用しています

 Size size = Director::getInstance()->getWinSize();
    auto renderTexture = RenderTexture::create((size.width/5)*3.98, (size.height/5)*3.45, Texture2D::PixelFormat::RGBA8888);
    renderTexture->beginWithClear(0.0f, 0.0f, 0.0f, 0.0f);
    Director::getInstance()->getRunningScene()->visit();
    renderTexture->end();
    renderTexture->saveToFile("screenshot.png" , kCCImageFormatPNG);

「スクリーンショット」+現在時刻+「.png」のようなファイル名として現在のシステム時刻を使用して画像ファイルを保存するにはどうすればよいですか?

4

1 に答える 1

0

システム時刻を取得するには、次の関数を使用するだけですtime(): docs

一緒にひもに接着する場合はstd::stringstream、たとえば使用できます。

#include <sstream>
#include <time.h>

//--- in your save method ---
std::stringstream filename;
filename << "screenshot_" << time(NULL) << ".png";

renderTexture->saveToFile(filename.str(), kCCImageFormatPNG);
于 2014-07-08T06:50:30.987 に答える