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
42
S
5
G
5
Posts: 407
Reputation: 5,711

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
63
S
22
G
14
Posts: 1,482
Reputation: 16,432

Post » Fri Jan 06, 2012 2:54 am

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

Post » Fri Jan 06, 2012 1:19 pm

Thanks Yann. It's working nicely.
B
42
S
5
G
5
Posts: 407
Reputation: 5,711

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
36
S
8
G
3
Posts: 328
Reputation: 7,757

Post » Thu Nov 29, 2012 7:22 pm

@EyeHawk
dunno share capx
B
63
S
22
G
14
Posts: 1,482
Reputation: 16,432

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
36
S
8
G
3
Posts: 328
Reputation: 7,757

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
63
S
22
G
14
Posts: 1,482
Reputation: 16,432

Post » Fri Nov 30, 2012 3:05 am

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

Post » Fri Nov 30, 2012 8:54 am

I've already provided a capx here
Passionate developer

If my work helped you to make your project, please consider making a donation :)
B
44
S
12
G
14
Posts: 630
Reputation: 10,985

Next

Return to How do I....?

Who is online

Users browsing this forum: AllanR, Artpunk, CataclysmicKitty, QuantumMMX and 5 guests