How to move or dragg the viewport

Get help using Construct 2

Post » Fri Jan 06, 2012 1:32 am

How could I move/dragg the viewport by holding down middle mouse button in my game, just like in construct 2 viewport?
So far I have managed to do this:
Cameraman:
Substract Cursor.X/2 from CurrentX
Substract Cursor.Y/2 from CurrentY

Cameraman:
Set X to Cameraman.CurrentX
Set Y to Cameraman.CurrentY

This works well, but returns view back to the starting point.
B
40
S
5
G
5
Posts: 405
Reputation: 5,657

Post » Fri Jan 06, 2012 2:18 am

Last edited by Yann on Sun Sep 14, 2014 12:02 pm, edited 1 time in total.
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Fri Jan 06, 2012 2:54 am

Nice example Yann, thanks.
ImageImage
B
25
S
6
G
8
Posts: 773
Reputation: 6,643

Post » Fri Jan 06, 2012 1:19 pm

Thanks Yann. It's working nicely.
B
40
S
5
G
5
Posts: 405
Reputation: 5,657

Post » Wed Nov 28, 2012 5:53 am

@Yann, great example! I wanting to apply this to touch. I replaced all the mouse expressions with touch ones, but it didn't work, is there something else I need to do?
B
34
S
8
G
3
Posts: 328
Reputation: 7,692

Post » Thu Nov 29, 2012 7:22 pm

@EyeHawk
dunno share capx
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Thu Nov 29, 2012 8:15 pm

@Yann, ok here it is:

http://www.learnrec.com/C2forum/TouchPanning.capx

I just replaced the mouse with touch , but I guess I'm missing something...
B
34
S
8
G
3
Posts: 328
Reputation: 7,692

Post » Fri Nov 30, 2012 2:06 am

@EyeHawk
add in event 2
System: dragging = 0

when you are "in touch" sMX and sMY gets constantly updated so on event 4
sMX and sMY are always equal to Touch.AbsoluteX and Touch.AbsoluteY so you have scroll to sSX + 0 , sSY + 0... no movement.
In the original capx it was a trigger "on click" (instantaneous) not "mouse is down" (continue)
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Fri Nov 30, 2012 3:05 am

@Yann - it works perfectly! You're a true C2 guru thanks again :)
B
34
S
8
G
3
Posts: 328
Reputation: 7,692

Post » Fri Nov 30, 2012 8:54 am

I've already provided a capx here
B
44
S
12
G
13
Posts: 628
Reputation: 10,471

Next

Return to How do I....?

Who is online

Users browsing this forum: h1k3, Unconnected and 0 guests