How do I scroll my map with Touch object?

Get help using Construct 2

Post » Tue Jan 19, 2016 11:48 am

Hi to all

my app is a 480x800px layout
the picture i have with a jpg map is 2459, 2459 in size
Image

How to scroll that map with the touch object
B
41
S
16
G
7
Posts: 1,750
Reputation: 9,963

Post » Tue Jan 19, 2016 12:57 pm

One way I can think of is you could create a sprite on touch, pin the map to it and is touching set sprite to touch.x, touch.y
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Tue Jan 19, 2016 1:34 pm

im trying but i dont get any good result
B
41
S
16
G
7
Posts: 1,750
Reputation: 9,963

Post » Tue Jan 19, 2016 1:44 pm

Why not?
What result are you getting?
What result do you expect?
What are the events you are using?
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Tue Jan 19, 2016 1:46 pm

imothep85 wrote:im trying but i dont get any good result


What effect are you looking for? Touch and drag?

https://dl.dropboxusercontent.com/u/100 ... index.html
B
58
S
25
G
14
Posts: 793
Reputation: 13,302

Post » Tue Jan 19, 2016 1:52 pm

touch and drag i have the same result has your index.html, but i dont want to see that empty space outside the map, i want the map stop whend the edges reach the edges of the layout size 480x800px
B
41
S
16
G
7
Posts: 1,750
Reputation: 9,963

Post » Tue Jan 19, 2016 2:03 pm

imothep85 wrote:touch and drag i have the same result has your index.html, but i dont want to see that empty space outside the map, i want the map stop whend the edges reach the edges of the layout size 480x800px


I understand that but if you limit the drag like this it should be good?

https://dl.dropboxusercontent.com/u/100 ... index.html
B
58
S
25
G
14
Posts: 793
Reputation: 13,302

Post » Tue Jan 19, 2016 2:08 pm

yeah thats perfect :D how you did that?
B
41
S
16
G
7
Posts: 1,750
Reputation: 9,963

Post » Tue Jan 19, 2016 2:28 pm

There are many ways of doing it. Like checking the maps X and Y values. So for example if you don't want the map to go more than -600px to the left then setup the events like this: if maps x is less than -600 then set map X to -599

And do this to limit left, right, top and bottom scrolling :)

You can also do it with sprites like this: https://dl.dropboxusercontent.com/u/100 ... 2/map.capx

There are many other ways to do it so I can't say this is the best one. But it works ;)
B
58
S
25
G
14
Posts: 793
Reputation: 13,302

Post » Tue Jan 19, 2016 5:06 pm

Good example, @Anonnymitet.
How would you do to drag an entire layer instead of just a sprite ?
B
38
S
16
G
5
Posts: 269
Reputation: 5,964

Next

Return to How do I....?

Who is online

Users browsing this forum: Google [Bot], Yahoo [Bot] and 27 guests