Problem with Game borders

Hello to all,

In my game the object, a square, can be zoomed and moved, but I would like that, in all cases, we can never see beyond the object. Let me explain, at the beginning of the game the object occupies the height of the screen, when I zoom in and move the object, let’s say upwards, I want that, whatever the size of the object, its top part should not go down lower than the top of the screen. The same if it is moved to the left, right or bottom.

I thank, in advance, the one who will understand my problem and who will provide me the solution.

What’s the object? It represents the camera view?
Maybe this action could help you, as it allows setting boundaries for the camera:

Hi Gruck
My object is a map, square, you can zoom and move it, (like Google map), but this map has limits and I want that, when it is zoomed and moved in any direction, the edge of the map stops at the edge of the screen, that you can never see the background. I have no idea what solution would help me. Also, I don’t really know Gdevelop, I still have a lot to learn. Thanks for your help.

Hi Loupblanc,
It would be more helpful if you post your current events to move the square map, but
You can check the square’s X position - if it is less than 0 for example, teleport it back to 0 coordinate.
For right side, check if the object X coordinate + object Width() is bigger than object Width() - if true, reset X position to object Width().
You can do this object reset position on Y coordinate too.

If you need more help, I hope other people can answer lol because I’m not very active here nowadays!

1 Like

Thanks Cat for your advice, I haven’t had time to get back into it yet, but hopefully soon.

1 Like

In the same style, do you know if it is possible to zoom the area under the cursor? To be clear, the reference point of an object is at the top left. However, when I zoom in on my map, the camera moves to the top left, rather than to the area where the mouse is.

I don’t see why it wouldn’t be possible. You decide where the camera is and the zoom factor.
If you want to center the camera on MouseX/Y, do so.

But you need to figure out how to make all your camera features work without conflicting with one another.
Sometimes, you may find helpful to create an invisible pointer object that serves as camera center and that you’ll move around as you wish.