Potential camera bug?

I’m making an 8-bit inspired pixel game and position the camera so that everything looks 2x the size like so:

auto cam = this->getDefaultCamera();
auto pos = cam->getPosition3D();
cam->setPosition3D(Vec3(pos.x, pos.y, pos.z * (1.0 / GAME_SCALE))); // scale is 2.0

I also made a function that can make sprites of a certain width and height with gfx taken from the same spritesheet I’m using for my background tiles, and for some reason this resets the game’s size to 1x size again. If I run this code:

auto src = Sprite::create("images/tiles.png"); // gfx used in the game as background tiles
auto texture = RenderTexture::create(3, 3, src->getTexture()->getPixelFormat());
texture->begin();
texture->end();

Everything is at 1x size again. I run the camera code the last thing I do in the onEnter method.
However, if I run the camera code inside a onTouchBegan method (so after the game started) I can zoom in again.

How can I structure my code so that the game starts at 2x?

One more thing - and I doubt that this is intented behaviour…
If I don’t run the second code block (so the game starts at 2x zoom), then minimize the window, then maximize it again, the zoom is at 1x. Is this a bug…?

What kind of scene are you using?

It’s inherited from the Scene class.

I think you need to call clear() first. Let me think about the rest.

Where should I call clear? Can you post some pseudocode?

auto sprite = Sprite::create("original.png");
auto renderTexture = RenderTexture::create(64, 64, Texture2D::PixelFormat::RGBA8888);
renderTexture->clear(0,0,0,0);
renderTexture->begin();
sprite->setAnchorPoint(Vec2(0, 0));
sprite->setPosition(Vec2(0,0));
sprite->visit();
renderTexture->end();
renderTexture->saveToFile("rendertexture.png", Image::Format::PNG);

Adding clear didn’t do anything, sorry.

I’m facing the same behaviour right now.
I’m using RenderTexture to create dynamic Textures and this resets the Camera zoom. In some cases the Textures are not even visible.
Do you have solved this @xerosugar???

Nope, wasn’t able to solve it… What I think I’ll do is to make a workaround for it that hides the problem.
I only do that kind of processing when I’m building the level (which only takes a few ms.), but when the level is ready, I could let the screen fade in from black or whatever, and before the level is revealed I reset the zoom to the one I want. You can for example run a delayed action to do that, and the delay only has to be a few milliseconds. Hope this helps.

Thanks for your reply.
I’m doing the same as you have described. Preloading the “dynamic” Textures before the Game starts. It’s a solution but not the best.
I’ve seen other Forum Postings from 2014 that are reporting this Bug… but it seems still to be present.