cocos 2d-x 3.15 微信分享总结

前端之家收集整理的这篇文章主要介绍了cocos 2d-x 3.15 微信分享总结前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

JS 部分的代码:shareWX:function()

{

auto size = Director::getInstance()->getWinSize();

auto pScreen = RenderTexture::create(size.width,size.height);
auto pCurScene = Director::getInstance()->getRunningScene();
pScreen->begin();
pCurScene->visit();
pScreen->end();
pScreen -> saveToFile(StringUtils::format("screen_capture.png"),Image::Format::PNG);
pScreen->cleanup();
JniMethodInfo Fanrncho_minfo;
bool isHave = JniHelper::getStaticMethodInfo(Fanrncho_minfo,"com/maple/madherogo/WechatHelper","share","(Ljava/lang/String)V");

}


native 端的代码OC or C++

void WechatHelper::share(const std::string & arg1,const std::string & arg2) { auto size = Director::getInstance()->getWinSize(); auto pScreen = RenderTexture::create(size.width,size.height); auto pCurScene = Director::getInstance()->getRunningScene(); pScreen->begin(); pCurScene->visit(); pScreen->end(); pScreen -> saveToFile(StringUtils::format("screen_capture.png"),Image::Format::PNG); pScreen->cleanup(); std::string img_path = FileUtils::getInstance()->getWritablePath() + "screen_capture.png"; WXMediaMessage* Fanrncho_message = [WXMediaMessage message]; [Fanrncho_message setThumbImage:[UIImage imageNamed:@"Icon-50.png"]]; WXImageObject* Fanrncho_img = [WXImageObject object]; Fanrncho_img.imageData = [NSData dataWithContentsOfFile:[NSString stringWithUTF8String:img_path.c_str()]]; Fanrncho_message.mediaObject = Fanrncho_img; SendMessageToWXReq* Fanrncho_req = [[[SendMessageToWXReq alloc] init]autorelease]; Fanrncho_req.bText =NO; Fanrncho_req.message = Fanrncho_message; Fanrncho_req.scene = WXSceneTimeline; [WXApi sendReq:Fanrncho_req]; }

原文链接:https://www.f2er.com/cocos2dx/338574.html

猜你在找的Cocos2d-x相关文章