• 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!

Android Can't find how to put limits on scrolling implementation

B

BagarraoEduardo

Guest
Hello all, I'm having a problem with scrolling.
To implement a scrolling system I have followed this tutorial and I find it really cool, but I can't make my scroll to stop on his limits.
Basically I wan't to populate a leaderboard and have a top scrolling limit, and a bottom scrolling limit.
I would like to ask for help to do this to you.

Here's my code:
  • Create
    Code:
    drag_offsetY = 0;
    
    flickVelY = 0;
    
    flick_power_calibration = 4;
    flick_power_reduction_each_step = 4;
    
    leaderboard_players = ds_list_create(); //leaderboard sample list
    
    y_origin = 10;
    
    ds_list_add(leaderboard_players, "uracilio");
    ds_list_add(leaderboard_players, "jucemiro");
    ds_list_add(leaderboard_players, "lipindio");
    ds_list_add(leaderboard_players, "semantico");
    ds_list_add(leaderboard_players, "telemovel");
    ds_list_add(leaderboard_players, "uracilio");
    ds_list_add(leaderboard_players, "jucemiro");
    ds_list_add(leaderboard_players, "lipindio");
    ds_list_add(leaderboard_players, "semantico");
    ds_list_add(leaderboard_players, "telemovel");
    ds_list_add(leaderboard_players, "uracilio");
    ds_list_add(leaderboard_players, "jucemiro");
    ds_list_add(leaderboard_players, "lipindio");
    ds_list_add(leaderboard_players, "semantico");
    ds_list_add(leaderboard_players, "telemovel");
  • Step

    Code:
    if( flickVelY != 0 )
    {
        flick_power = abs(flickVelY);
        flick_direction = sign(flickVelY);
        if( flick_power > flick_power_reduction_each_step ) 
        {
            y += (( flick_power / flick_power_calibration) * flick_direction);
            flickVelY -= flick_power_reduction_each_step * flick_direction;
        }
        else
        {
            flickVelY = 0;
        }
    }
  • Global Drag Start

    Code:
    drag_offsetY = y - event_data[?"posY"];

  • Global Dragging

    Code:
    y = event_data[?"posY"] + drag_offsetY;
  • Global Drag End

    Code:
    flickVelY = event_data[?"diffY"];
  • Global Left Down

    Code:
    flickVelY = 0;
  • Draw

    Code:
    draw_self();
    
    var index = 0;
    var i;
    var line_spacing = y_origin;
    var x_offset = 10;
    
    for(i = 0; i < ds_list_size(leaderboard_players); i++)
    {
        draw_text( x - (sprite_width / 2) + x_offset , y - (sprite_height / 2) + line_spacing, string(index) + " - " + ds_list_find_value(leaderboard_players, i));
        line_spacing += 15;
        index++;
    }

I also show the video of game's scrolling current state, so you could understand better :)
Thanks in advance guys! :D



Best Regards, Eduardo
 
Top