Scrolling page using GML (free?)

N

NoFontNL

Guest
As the title says, I am searching for a way to scroll vertical to the bottom of the room and up depending on how you 'swipe'. I think we all have seen something like this before, and if not in games, take for an example whatsapp. Like scrolling through messages.

But the problem is, your mouse_y variable changes everytime the camera's view moves down, so it'll create a infinite loop (until you're at the bottom or top of the room). Is there an alternative, or a solution for my problem?
 
N

NoFontNL

Guest
Tried this but still doesn't work...
Code:
    if (device_mouse_check_button_pressed(0,mb_left)) {
        touch_y = device_mouse_y(0); 
        pressed = true;
    }
    if (device_mouse_check_button_released(0,mb_left)) {
        pressed = false;   
    }
    if pressed    {
        y += device_mouse_y(0) - touch_y;
    }
 

Neptune

Member
Take a look at what ichanged in your first condition.
As for your actual movement approach, i didnt look at it, but what i changed was probably the root of your infinite scrolling.

Tried this but still doesn't work...
Code:
    if (device_mouse_check_button_pressed(0,mb_left)) && !pressed {
        touch_y = device_mouse_y(0);
        pressed = true;
    }
    if (device_mouse_check_button_released(0,mb_left)) {
        pressed = false; 
    }
    if pressed    {
        y += device_mouse_y(0) - touch_y;
    }
 

TsukaYuriko

☄️
Forum Staff
Moderator
Please define "doesn't work".

What are you expecting to happen?
What happens instead?


That aside, I don't see you updating touch_y anywhere after the initial touch, so you will be adding an increasing amount of momentum with every movement, adding the momentum of all steps since the first touch instead of the momentum since the last step.
 
N

NoFontNL

Guest
My finger moves 5 pixels to the top, camera view moves 5 pixels down.
My finger moves 5 pixels to the bottom, camera view moves 5 pixels up.
 
N

NoFontNL

Guest
When I have 'short' swipes, it works fine, but when I hold my finger on the screen and swipe once, the view goes up and down and up and down and so on. I use the Smooth Camera tutorial from Shaun Spalding and have a object, that goes up when you swipe down and vice versa, and the camera follows it. The larger amount I swipe the larger the amount it goes up and down and that stuff. I hope someone find the problem, because I have half working code right now lol.
 
Top