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).
So I want to move the map at left/right by scrolling it or by using two buttons. I searched for an example, but I found nothing.
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 ?
Why not? There are no laws against it.
Have you considered using the “Drag camera with the mouse (or touchscreen)” extension :
Thanks a lot MrMen I can use it too extensions are better then writing the code myself
It works perfectly, thank you!!
Thank you too for helping me, this method worked too, but I’ll use the suggestion from Mr!
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!
How are you implementing it? If you can provide a screen snip of the events that determine the scrolling, we can work out a solution that fits.
You can put a condition if camera x < 1000 to code or limit the camera boundaries
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.
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.
Like that? yes, it’s also fine.
In most cases re-usable is absult not necessary and not really easier/harder in both ways.
Yes, something like that.
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!!