Seamless Map Scrolling?

Get help using Construct 2

Post » Sat May 16, 2015 8:33 am

I want to create a seamless map scrolling system, for level selecting in a game.

Here is an example of a seamless map:
Image

What I want to accomplish is the following:
User swipes the map in any direction, the viewport scrolls in that direction using Scroll To
The map/viewport should wrap, giving the impression that the map wraps around, it should be smooth, not just snap to the opposite side
There will be icons on the map, which will be clickable.

Here is a CAPX, with the map texture and a few buttons on the map, you can click and drag the map.
https://www.xgamedev.com/zips/seamlessmap.zip

Anyone know how to do this?

Thanks
B
43
S
9
G
7
Posts: 58
Reputation: 7,540

Post » Sat May 16, 2015 9:59 am

I did it for one of my projects here https://www.scirra.com/forum/viewtopic.php?f=180&t=120509.

The maths for plotting object movements along it is a little complicated but if you just want to scroll a map then simply create say 2 copies of the image for the x axis and 2 for the y axis and when you reach the edge of one reposition the opposite edge of another copy at that position.

The map needs to be bigger than the window, and for performance you may need to break the large image into smaller sections.

If the map is smaller than your window size then you'll need to use more copies.
B
43
S
23
G
21
Posts: 735
Reputation: 12,132

Post » Sun May 17, 2015 4:14 pm

For scrolling:

Make one 16x16 object and stretch that to fit the screensize. Break the high resolution map up in smaller pieces and 'pin' those to the 16x16 object. Make the 16x16 object draggable. This way you only have to animate one object and have a map that can be higher than 2000x2000 pixels.

For zooming:

Now make a global variable named "Zoom' which has a default of 1 and set the layer scale to match this variable. On mousewheel-up add 0.2 to the variable 'Zoom' and on mousewheel-down subtract 0.2. On every tick set layer scale to 'Zoom'. If Zoom < 1 Zoom = 1.

I hope this helps. I cannot open your file for i am using the last stable version and you hve a newer version of C2.
B
54
S
7
G
8
Posts: 150
Reputation: 5,817

Post » Sun May 17, 2015 4:19 pm

@UberDark, thanks, the problem isnt the scrolling, its the seamless scrolling. To be more clear, if the user gets to the far right side off the map, they should start seeing the far left side of the map again, almost like place the maps next to each other.

But, I was able to solve this. Made the map into tiles, when a map tile is off screen, it moves itself to the other side, depending on which way the user is scrolling. The map icons are pinned to the tiles
B
43
S
9
G
7
Posts: 58
Reputation: 7,540

Post » Sun May 17, 2015 8:58 pm

I see! Cool glad you figured it out. Sorry i didn't understand.
B
54
S
7
G
8
Posts: 150
Reputation: 5,817

Post » Mon May 18, 2015 9:24 am

Here is the capx, if anyone wants to do something similar

http://xgamedev.com/zips/seamlessmap_fixed.zip

Enjoy!
B
43
S
9
G
7
Posts: 58
Reputation: 7,540


Return to How do I....?

Who is online

Users browsing this forum: MadSpy and 8 guests