I’m trying to pre-render an image which should represent an isometric terrain (I’m not using TileMap, and I don’t want to). Therefor I need to draw the same Texture/Sprite/Image multiple times.
One way to do it, is to create a sprite for each tile and then call visit between RenderTexture’s begin() and end(). Somehow I don’t like this approach, because it seems like a waste of resources to me.
The way I like it, and also got it working to draw the same texture multiple times, is with Texture2D’s method drawAtPoint/drawInRect. But RenderTexture doesn’t “pick” up those draw calls.
Code:
auto renderTexture = RenderTexture::create(512, 512);
renderTexture->beginWithClear(1.0f, 0.0f, 0.0f, 0.5f);
texture->drawAtPoint(Point(100, 110));
sprite->setPosition(200, 100);
sprite->visit();
renderTexture->end();
renderTexture->saveToFile("rt.png", kCCImageFormatPNG);
The sprite is drawn, but the texture is not. If I draw the texture to screen, it’s drawn correctly.
Can someone please give me directions how to solve this. Thank you.