1. Hey! Guest! The 35th GMC Jam will take place between November 28th, 12:00 UTC - December 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice

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

Discussion in 'Game Design, Development And Publishing' started by BagarraoEduardo, Oct 12, 2019.

  1. BagarraoEduardo

    BagarraoEduardo Member

    Joined:
    Aug 4, 2019
    Posts:
    7
    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
     
  2. FrostyCat

    FrostyCat Member

    Joined:
    Jun 26, 2016
    Posts:
    4,607
    Yal likes this.

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