Hi, I’m trying to make a “scroll left/right” map where you can click to choose the level to play. I want to make something like the screenshot below (it’s from a famous game, I don’t know if I can write the name).
Hello friend, you can use mouse wheel condition for this example. Say when you scroll down the mouse wheel, make camera go right and when you scroll up , make camera go left. Or you can put invisible objects to both side of screen and when mouse on the appropriate side let camera go that side. I will drop both examples for your use. Feel free to use any of them and inform me if you did it successfully please ?
Is there a way to stop infinite scrolling? Because the scroll horizontal with touchscreen works, but I can’t find a way to put a limit (I do not want to scroll at right side the initial part of the map, for example). How do I can put a limit to the scrolling thing? Thank you in advanced!
In theory yes, but that doesn’t work in practice.
If you drag fast enough you can go 180 over the limit and be stuck forever.
Even slowly you’ll be stuck at 1000 or 1001.
This works fine for me:
It looks like limits may be integrated into the drag action soon. That would make sense because almost always we don’t want to drag endlessly. https://github.com/4ian/GDevelop/pull/3703
The downside of @kingwulfgar’s and @jack’s suggestions is that the limits are hardcoded, making the script very specific, and possibly makes for a set of single-use events.
I think @GoodReason would be better off placing marker objects on the scene that denote the outter limits for the camera (i.e. 2 marker objects). Then check whether the camera boundaties exceed those markers (2 events), and reset the camrea position so it falls within them.
Although this is a bit more work, it is a more fexible and re-usable technique.
Re-usable as in can be used in multiple scenes without having to change the code/events, especially if the scenes are different sizes.
This technique/idea can also be applied when the camera follows the player in a size limited environment.
This technique makes it easier to modify the limits - just move the marker. I’ve used this method for a horizontally scrolling inventory - because the marker moves as the inventory list changes, there’s no calculations to do.
So by creating those two objects and putting them on the map and after using this code it’ll work??
I’m unable to test it out because my pc got broke. It doesn’t show anything on the screen. But fortunately I’ve a backup of my game ahah (sorry for my bad english, but I’m italian and I studied english at school). Thank you guys for your big help!!