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+lua[2]](/uploads/allimg/131030/110J64609-0-lp.jpg)








