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…?