Which is better in terms of performance, appearance, image sharpness etc. between camera zoom x2 or just resizing the objects x2?
Probably better performance zooming in vs resizing objects
For the most part, no difference, so long as you’re zooming/resizing in integers (1x, 2x, 3x, not 1.375x or something).
It seems that text object get blurred when using camera zoom, how to fix this?
Replacing it with bitmap text instead?
Do you want the text to zoom or is it fine staying the same size? Is it text you can move to another layer that doesn’t zoom?
The text should also zoom.
Moving the text to another layer messed up the position, because I set the text position based on the object (in the layer that is zoomed in).
Its an inventory window.
I previously thought that maybe its possible to move the text to another layer then change the font size to originalSize x cameraZoomLevel, but the position it self become mismatch after zoom.
Wait probably its because I forgot to center the camera on the new layer, gotta try it later.
If you are zooming a camera/rescaling, I’d recommend using Bitmap text as it scales the same way images do.
Whereas Text/BBtext objects use your Operating System’s font renderer, which just means you’re blowing up an antialiased small text image, which will look blurry.
You can convert a .ttf into a bitmap font using https://snowb.org
Hmm actually that is an interesting idea, when you try it later let me know what happens.
Nope doesn’t work, I guess I am gonna use bitmap font.
Bummer it sounded promising.
If an object A positioned at (100,100) - origin point of object is in its center.
When the layer got zoomed in we will see in the monitor that the object position seems changed while actually its position is still at (100,100).
If I have object B (origin point is at the center) and position it at object A and object B is on different layer than object A when the game is run object B will be in the center of object A, and now if the layer which object A is placed got zoomed object B won’t be in the center of object A anymore.
Is there any math formula to know the new position for the object B so it can be in the center of objects A again? Like need to compensate the difference after the zoom, I think it can be calculated but I don’t know how.
To clarify, while the visuals may change, positions (actual x/y locations as far as the engine is concerned) do not change when zooming. Are you by chance only zooming one layer’s camera?
Each layer has a unique camera, so if you’re only zooming one camera (You don’t zoom a layer, you zoom that layer’s camera), you’re going to basically be breaking any similar visual positions between the two.
I would imagine the position differences would be inverse factor to whatever zoom factor you’re using, but I’m not 100% sure on the specific math.
Yup I tried to zoom one of the camera layer, but the object in another layer that the camera is not zoomed should be able to keep up with the position of the layer that is zoomed.
Yes although the visual is different the x,y position is actually the same indeed.
For example a player object have text object positioned right above the head, the player is in layer A and the text is in the layer B.
Regardless of the zoom in layer A be it 1x 2x 3x 4x how to make the text in layer B keep being above the head of the player?
Either you must also zoom layer B by the exact same amount to keep the render positions the same, or you’ll need to figure out a mathematic formula that can approximate the same.
You can at least find out the “visual” difference by temporarily adding a text item, and have it display the CursorX(“yourlayerhere”,0) or CursorY() expressions as a string.
I’d do something like "Normal X: " + CursorX(“non-zoomedlayerhere”,0) + NewLine() + "Zoomed X: " + CursorX(“zoomedlayerhere”,0)
That way you can see the positioning on both layers and compare the mathematical difference.
Now that I think about it its like a simple Cartesian x,y problem.
Using camera center as 0,0 now if point A is positioned at 1,1 then x2(if its in the game then zoomed x2) then the “visual” location become 2,2 right?
I think how it works:
- Get the center position of the camera, either sceneWidth/2 and sceneHeight/2 or cameraWidth/2 and cameraHeight/2 not sure which.
- For X position:
PointA and PointA2(new position after zoom)
If PointA.X is less than camera center.X then the new “visual” position of PointA2 after zoom would be: camera center.X - ((camera center X - PointA.X) * zoom Value)
If PointA.X is more than camera center.X then : camera center.X + ((PointA.X - camera center.X) * zoom value)
- For Y position just tweak it a little.
I managed to move the text object to keep up with the other layer that is zoomed, the squares is in the base layer and the text is in the top layer.
Only works for the X axis currently, not sure why the Y axis doesn’t work.
Only working on the black square and green text for now, so ignore the other text and square.
The green text have correct X position but not Y position.
Here is 4x zoom + fontsize* zoomValue:
And the text is not blurry because its not get scaled up but instead the font size is increased, the Y position is still not correct though.
It looks impressive and yet at the same time I have no idea what’s going on here.
Its working now
@Lucky-j so its about zooming a camera layer and while using text object but the text object not get blurry and still sharp, its alternative options if you don’t want to use bitmap text.
The squares are in the base layer which will be zoomed, the text is in the different layer and the camera zoom stay the same but zoom effect is achieved by moving the position and changing font size using events.
Well it’s brilliant now, it looks like it’s working perfectly I’m going to add your screen shot into my tutorials folder so I can study it later. The part I didn’t understand was changing the position of the squares but no doubt I’ll understand why when I try to recreate it later.
Is it to keep position when zoomed?
The square actual position didn’t change actually, the (x,y) is still the same but because of the zoom-in, only the visual position is changed.
Although I set the square in a certain position, because it simulates an inventory pop up windows so the object position is fixed.