1
votes

I need to create an empty sprite as a container and add there in different positions different sprites created by using different images. At the end I need to save the result which in added as child into the container sprite as an image - .png for example.

How I can do that?

1

1 Answers

1
votes

You can use RenderTexture and call visit method of Sprite. Here is a sample code:

RenderTexture* renderTexture = RenderTexture::create(width, height, Texture2D::PixelFormat::RGBA8888);
renderTexture->begin();
sprite->visit();
renderTexture->end();
renderTexture->saveToFile("snapshot.png", Image::Format::PNG);