Adding wrapping to custom text function

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

  1. Gleb

    Gleb Member

    Joined:
    Aug 14, 2019
    Posts:
    1
    Hi everyone,

    Followed a tutorial video (GameMaker Studio 2: Text-Based Game Tutorial: One letter at a time Script [EP3]) to make text appear one character at a time like many games do.

    My goal is to modify this script to include text wrapping similar to "draw_text_ext".

    The script:

    Code:
    //draw_text_speed(x,y,string,speed)
    //x and y are relative
    //string is the string
    //speed is how fast
    
    if (argument[0] == "Reset"){
        draw_text_speed_value = 1;
        draw_text_speed_timer = 0;
        return;
    }
    
    draw_text_speed_txt = argument[2];
    
    if !(variable_instance_exists(id,"draw_text_speed_timer")){
    
        draw_text_speed_timer = 0;
    
    } else {
    
        draw_text_speed_timer++;
    
    }
    
    if !(variable_instance_exists(id,"draw_text_speed_value")){
    
        draw_text_speed_value = 1;
    
    }
    
    if (draw_text_speed_timer >= argument[3]){
    
        draw_text_speed_value++;
        draw_text_speed_timer = 0;
    
    }
    
    draw_text(argument[0],argument[1],string_copy(draw_text_speed_txt,1,draw_text_speed_value));
    
    Just got back into gmx after a good 4 year break. Any idea on how to tackle this?

    Thanks in advance
     
  2. CedSharp

    CedSharp Member

    Joined:
    Sep 5, 2016
    Posts:
    642
    You can take a look at how I implemented wrapping in my dialog box asset (it's currently free on the marketplace here)
    More specifically, check the "parsing" folder which contains the script that handle the wrapping.

    Hope this helps!
     

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