Option to show the camera bounds of the in-game view
Is your feature request related to a problem? Please describe.
I'm making a little GBA game with tons of parallax. So I use the parallax feature of the Tiled editor to represent that. But I've noticed that the parallax appears far more extreme in the editor, because my view is likely zoomed out significantly, which scales the parallax scrolling.
So I thought it'd be nice to be able to see exactly what's going to appear in-game while editing, in the form of a little box in the center of the screen that has the same size as the in-game view.
This will likely benefit level designs that don't use parallax, as well, since level designers can more clearly see what's on-screen at any given moment.
Describe the solution you'd like.
I suggest adding an option in, say, the map properties to specify the size of the in-game view (such as 240×160 pixels in my case). In addition, there should be a toggle in the "view" menu that simply draws a rectangle of that size in the middle of the viewport.
Describe alternatives you've considered.
I've also come up with a simple workaround that I'm currently using, in which I have an object layer with a parallax factor of 0 (so it's fixed to the viewport) with a rectangle object in the center. This works pretty well, and the only real downsides are that it's a bit hacky and will require that I inform the engine that this isn't an actual object.
I'm honestly fine with it, so this proposal is really more about making something more standardized and less hacky than filling some gap in the editor's feature set.
EDIT: This hack also has the downside that the inside of the rectangle object is slightly tinted. It's not a lot, but it is slightly noticable.
as a different hack workaround, you could use an image layer with an image the size of your viewport, because i bet you dont use image layers, so you wouldnt need to special case them beyond ignoring them which you probably hopefully ideally already do
but to add onto this, being able to lock the camera in some way shape or form, ideally with scriptability to allow for more complicated camera behaviours, would probably be useful
I'm surprised there wasn't already an issue for this, with how much this request has been discussed already. Thanks for opening one! I previously used a frame of 4 rectangles instead to avoid the fill, but now I have a custom class that disables the fill instead. Still, I dislike having these objects cluttering my map files and would much rather this be a distinct Tiled feature.
Additional thoughts, some of these are from earlier discussions:
- I think "viewport" is a better term for this feature.
- Allow adding multiple viewports. This would allow representing variable aspect ratios or zoom levels (if the user adds the max/min viewports), portrait/landscape mode on mobile, etc.
- Being able to toggle them independently as well as being able to show/hide all would be fantastic.
- For games that don't have a specific viewport size but only a viewport ratio and show the map zoomed at various levels in that viewport (as you might see in factory-builder and strategy games), allow setting viewports as aspect ratios. In this case, it might also be useful to set a min/max zoom, beyond which the viewport will also zoom in/out with the map, for when the user needs to zoom further for editing than the game would allow.
- It would be cool if rather than being fixed on the screen like parallax layers, the viewports could clamp to the map bounds (on finite maps only), especially if this could be done independently for the inner bounds, so both inner and outer bounds accurately represent camera position on different parallax positions without having to be super-careful with scrolling.
- If any clamping is done, it would also be useful to set a margin on the map to clamp to (0px on all sides by default), perhaps as map properties, for those who include a hidden margin on their maps for the purposes of screenshake, hiding level transitions, etc.