Cocos2d-x3.0 RenderTexture(一) 保存(2)

来源:未知 责任编辑:责任编辑 发表时间:2014-05-26 10:56 点击:
< d; ++i) { float difx = end.x - start.x; float dify = end.y - start.y; float delta = (float) i / distance; _brushs.at(i)->setPosition(Point(start.x + (difx * delta), start.y + (dify * delta))); _brushs.at(i)->setRotation(rand() % 360); float r = (float) (rand() % 50 / 50.0f) + 0.25f; _brushs.at(i)->setScale(r); _brushs.at(i)->setColor(Color3B(rand() % 127 + 128, 255, 255)); _brushs.at(i)->visit(); } } _target->end(); } void LayoutTest::saveImage(cocos2d::Ref *sender) { static int counter = 0; char png[20]; sprintf(png, "image-%d.png",counter); char jpg[20]; sprintf(jpg, "image-%d.jpg",counter); _target->saveToFile(png, Image::Format::PNG); _target->saveToFile(jpg, Image::Format::JPG); //向本地写入 std::string fileName = FileUtils::getInstance()->getWritablePath() + jpg; auto action1 = DelayTime::create(1); auto func = [&,fileName]() { auto sprite = Sprite::create(fileName); layout->addChild(sprite); sprite->setScale(0.3f); sprite->setPosition(Point(40, 40)); sprite->setRotation(counter * 3); }; runAction(Sequence::create(action1,CallFunc::create(func), NULL)); counter++; } void LayoutTest::clearImage(cocos2d::Ref *sender) { _target->clear(CCRANDOM_0_1(), CCRANDOM_0_1(), CCRANDOM_0_1(), CCRANDOM_0_1()); }

发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
用户名: 验证码:点击我更换图片
最新评论 更多>>

推荐热点

  • cocos2d-x学习笔记(19)--label 、label atlas
  • cocos2d-x学习笔记(23)--地图的使用3--CCTMXLayer
  • Cocos2d-x学习(一):HelloWorld
  • cocos2dx在xcode下开发,编译到android上(2)
  • cocos2d 设置屏幕默认方向
  • cocos2d-x学习笔记(22)--地图的使用2(TMX) --Z-Order、AnchorPoi
  • Cocos2d-x 2.0 之 Actions “三板斧” 之一
  • cocos2d-x学习笔记(18)--游戏打包(windows平台)
  • cocos2d-x学习笔记(16)--spritesheet(精灵表单)
网站首页 - 友情链接 - 网站地图 - TAG标签 - RSS订阅 - 内容搜索
Copyright © 2008-2015 计算机技术学习交流网. 版权所有

豫ICP备11007008号-1