1. Hey! Guest! The 34th GMC Jam will take place between August 22nd, 12:00 UTC (Thursday noon) and August 26th, 12:00 UTC (Monday noon). Why not join in! Click here to find out more!
    Dismiss Notice

GMS 2 Can't Swap Code From File To File (Gesture)

Discussion in 'Programming' started by twalkerp, Aug 14, 2019.

  1. twalkerp

    twalkerp Member

    Joined:
    Oct 12, 2018
    Posts:
    27
    I realized that I have my zoom in/out script for mobile backwards. I accidentally put zoom IN for pinch in, and vice versa with pinch out.

    I figured I could just swap the code and be done, but it's acting extremely weird and doesn't want to work when I do that.

    Any Ideas?


    Current Pinch IN Gesture (zooms in, but should zoom out)
    Code:
    var _scale = event_data[? "relativescale"];
    var _w = camera_get_view_width(view_camera[0]);
    var _h = camera_get_view_height(view_camera[0]);
    var _x = camera_get_view_x(view_camera[0]) + (_w / 2);
    var _y = camera_get_view_y(view_camera[0]) + (_h / 2);
    
    _w *= _scale;
    _h = _w * (room_height / room_width);
    _x -= _w / 2;
    _y -= _h / 2;
    
    camera_set_view_size(view_camera[0], clamp(_w,room_width/1.4,room_width/1.4), clamp(_h,room_height/1.4,room_height/1.4));
    
    Current Pinch OUT Gesture (zooms out but should zoom in)
    Code:
    var _scale = event_data[? "relativescale"];
    var _w = camera_get_view_width(view_camera[0]);
    var _h = camera_get_view_height(view_camera[0]);
    var _x = camera_get_view_x(view_camera[0]) + (_w / 2);
    var _y = camera_get_view_y(view_camera[0]) + (_h / 2);
    
    _w *= _scale;
    _h = _w * (room_height / room_width);
    _x -= _w / 2;
    _y -= _h / 2;
    
    camera_set_view_pos(view_camera[0], clamp(_x,0,room_width/2), clamp(_y,0,room_height/2));
    camera_set_view_size(view_camera[0], clamp(_w,0,room_width), clamp(_h,0,room_height));
    
    As mentioned, I tried just swapping the code but it does not work. Any ideas?

    Thanks
     
  2. twalkerp

    twalkerp Member

    Joined:
    Oct 12, 2018
    Posts:
    27
    any ideas?
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice