• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Solved - How to pan a camera without snapping?

K

krugen

Guest
GMS2
MOBILE
GESTURE

I followed the video by GM Wolf, but the camera snaps from the 2nd drag onwards.

I pressed and held down mb_left, move the mouse around, the camera pans smoothly.
I released the mouse.
I pressed and held down mb_left again, move the mouse around, the camera snaps back to the upper left corner.

By GMWolf:

I read a few old threads:
https://forum.yoyogames.com/index.p...mobile-camera-drag-gesture.66420/#post-396590

https://forum.yoyogames.com/index.p...camera-global-drag-gesture.66184/#post-395574

I tried and nothing works.


Update:

So the GMWolf video works out for me as well.

What did I do?

My game view is 640 x 360. The full area is 1280 x 720. But when I launched the game, the game window gets scaled up to 1280 x 720. This happens because my room size is 1280 x 720.

So I added: window_set_size(640, 360) and every tutorials works now.

However, when I run the program on my phone, the drag is not very responsive at all. I can drag a little to the right only. The 2nd drag snaps back to (0, 0). It works perfectly on desktop.
 
Last edited by a moderator:
K

krugen

Guest
This is so frustrating man.

I ended up using mouse function to solve this. I am so worry for my future.

in create event:
x1 = -1;
y1 = -1;

step event
Code:
var mx = display_mouse_get_x();
var my = display_mouse_get_y();

if (mouse_check_button(mb_left))
{
    camX += (x1 - mx)/2;
    camY += (y1 - my)/2;
    
    camera_set_view_pos(global.camera, camX, camY);   
}

x1 = mx;
y1 = my;
From FriendlyCosmonaut:
 

Luyou

Member
This is so frustrating man.

I ended up using mouse function to solve this. I am so worry for my future.

in create event:
x1 = -1;
y1 = -1;

step event
Code:
var mx = display_mouse_get_x();
var my = display_mouse_get_y();

if (mouse_check_button(mb_left))
{
    camX += (x1 - mx)/2;
    camY += (y1 - my)/2;
   
    camera_set_view_pos(global.camera, camX, camY);  
}

x1 = mx;
y1 = my;
From FriendlyCosmonaut:
Does this works fine on mobile?
 
Top