
<1>JNSaveScreenUtils.h
//// JNSaveScreenUtils.h// JNTest//// Created by jianan on 15/6/3.////#ifndef __JNTest__JNSaveScreenUtils__#define __JNTest__JNSaveScreenUtils__#include "cocos2d.h"USING_NS_CC;#include<string>using namespace std;#define winSize Director::getInstance()->getWinSize()class JNSaveScreenUtils : public Ref{public: JNSaveScreenUtils(); ~JNSaveScreenUtils(); static JNSaveScreenUtils* getInstance(); voID captureScreen(string @R_502_6852@name);private: CC_SYNTHESIZE(string,_save@R_502_6852@Path,Save@R_502_6852@Path);};#endif /* defined(__JNTest__JNSaveScreenUtils__) */<2>JNSaveScreenUtils.cpp //// JNSaveScreenUtils.cpp// JNTest//// Created by jianan on 15/6/3.////#include "JNSaveScreenUtils.h"using namespace utils;static JNSaveScreenUtils* instance = NulL;JNSaveScreenUtils::JNSaveScreenUtils(){ }JNSaveScreenUtils::~JNSaveScreenUtils(){ }JNSaveScreenUtils* JNSaveScreenUtils::getInstance(){ if(!instance){ instance = new JNSaveScreenUtils(); } return instance;}voID JNSaveScreenUtils::captureScreen(string @R_502_6852@name){ //voID captureScreen(const std::function<voID(bool,const std::string&)>& afterCaptured,const std::string& @R_502_6852@name); ::captureScreen([](bool b,string name){ log("the pic is saved: %s,@R_502_6852@ name:%s",b?"success":"fIEld",name.c_str()); },@R_502_6852@name); _save@R_502_6852@Path = @R_502_6852@Utils::getInstance()->getWritablePath() + @R_502_6852@name;}<3> bool HelloWorld::init(){ ////////////////////////////// // 1. super init first if ( !Layer::init() ) { return false; } this->setTag(999); Sprite* sp = Sprite::create("HelloWorld.png"); sp->setposition(Vec2(winSize.wIDth/2,winSize.height/2)); this->addChild(sp); scheduleOnce(schedule_selector(HelloWorld::Main),1.0f); return true;}voID HelloWorld::Main(float dt){ string @R_502_6852@Path = JNSaveScreenUtils::getInstance()->getSave@R_502_6852@Path(); //利用截屏图片来创造新的精灵 Sprite* sp = Sprite::create(@R_502_6852@Path); sp->setposition(winSize.wIDth/3,winSize.height/3); addChild(sp);} 总结 以上是内存溢出为你收集整理的cocos2dx 3.2截屏功能全部内容,希望文章能够帮你解决cocos2dx 3.2截屏功能所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)