Skip to content

Instantly share code, notes, and snippets.

@tklee1975
Created September 7, 2015 18:34
Show Gist options
  • Save tklee1975/4605a2282b797776df4f to your computer and use it in GitHub Desktop.
Save tklee1975/4605a2282b797776df4f to your computer and use it in GitHub Desktop.
Snippet of using RenderTexture with CocosStudio UI
void RenderTexTest::testUsingCocos(Ref *sender)
{
Node *rootNode = CSLoader::createNode("GameOverDialog.csb");
rootNode->setScaleY(-1);
rootNode->setAnchorPoint(Vec2(0, 1.f));
RenderTexture *texture = RenderTexture::create(320, 400, Texture2D::PixelFormat::RGB888);
// http://www.learn-cocos2d.com/2011/12/how-to-use-ccrendertexture-motion-blur-screenshots-drawing-sketches/
texture->setClearColor(Color4F::BLUE);
texture->begin();
rootNode->visit();
texture->end();
auto sprite = Sprite::createWithTexture(texture->getSprite()->getTexture());
int x = Director::getInstance()->getWinSize().width / 2;
sprite->setPosition(Vec2(x, 200));
addChild(sprite);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment