GameMaker Help with overlapping textboxes

O

OmegaTT

Guest
Hello, first post here, I am a recent user of Game Maker: Studio 2 (I have used GMS1 so I'm a bit familiar with GML) And I was trying to develop a textbox system for an RPG, but whenever I test it, the second textbox (activated by a sign object) overlaps with the text on the first textbox, but only after reading it the first time. Here is the code I used:

obj_textbox
> Create Event:

Code:
//image alpha is used because I use a sprite as a collision to detect where the player is.
image_alpha = 0;
scr_InitializaDialog1();
>> Step Event:

Code:
scr_DisplayConvoText();
x = obj_player.x;
y = obj_player.y;
>>> Draw GUI Event:

Code:
scr_DrawDialog();
>>>> Key press - Space Event:

Code:
if ((distance_to_object(obj_OFASignA) < 1) && (!active))
{
    convo_test_1(); //this is a script
}

if ((distance_to_object(obj_OFASignB) < 1) && (!active))
{
    convo_test_2(); //this is a script
}

Here are the scripts used:

-scr_InitializeDialog1:

Code:
padding = 50;


width  = window_get_width() - (padding * 2);
height = 200;
xOrigin = padding;
yOrigin = 10;


borderSize = 20;
innerBoxWidth  = width  - borderSize;
innerBoxHeight = height - borderSize;
innerBox_xOrigin = xOrigin + (borderSize / 2);
innerBox_yOrigin = yOrigin + (borderSize / 2);


avatarscale = 2;
avatar_xOrigin = innerBox_xOrigin + 30;
avatar_yOrigin = innerBox_yOrigin + 27;

text_xOrigin = avatar_xOrigin + 200;
text_yOrigin = innerBox_yOrigin + 30;


for (i = 0; i < 100; i++;)
{
    dialog[i, 0] = -1;
    dialog[i, 1] = "";
}

active = false;
convoDialogCount = 0;
convoIndex       = 0;
spriteToDisplay  = -1;
stringToDisplay  = "";
currCharIndex = 1;
-scr_DisplayConvoText:

Code:
if ((currCharIndex) < (string_length(dialog[convoIndex, 1]) + 1))
{
    spriteToDisplay = dialog[convoIndex, 0];
    stringToDisplay += string_char_at(dialog[convoIndex, 1], currCharIndex++);
}
else
{
    if (keyboard_check_pressed(vk_space))
    {
        convoIndex++
        stringToDisplay = "";
        currCharIndex = 1;
   
        if (convoIndex == convoDialogCount)
        {
            convoDialogCount = 0;
            active = false;
        }
    }
}
-scr_DrawDialog:

Code:
draw_set_font(fnt_Dialog);

if (active)
{
    draw_set_color(c_white);
    draw_rectangle(xOrigin, yOrigin, xOrigin + width, yOrigin + height, false);

    draw_set_color(c_black);
    draw_rectangle(innerBox_xOrigin, innerBox_yOrigin, innerBox_xOrigin + innerBoxWidth, innerBox_yOrigin + innerBoxHeight, false);
 
    draw_set_color(c_white);
    draw_text(text_xOrigin, text_yOrigin, stringToDisplay);
    draw_sprite_ext(spriteToDisplay, -1, avatar_xOrigin, avatar_yOrigin, avatarscale, avatarscale, 0, c_white, 1)
}
-scr_AddDialogLine:

Code:
dialog[convoDialogCount, 0]   = argument0;
dialog[convoDialogCount++, 1] = argument1;
-convo_test_1:

Code:
active = true;
convoIndex = 0;

scr_AddDialogLine(spr_signA, "* Welcome to Ome Forest!");
scr_AddDialogLine(spr_signA, "* The most beautiful Forest on Alphaland!");
scr_AddDialogLine(spr_signA, "* You are probably wondering where\n   you are or why are you here,\n    aren't you? well...");
scr_AddDialogLine(spr_signA, "* Questions will be answered soon...");
scr_AddDialogLine(spr_signA, "* For now, go around the forest,\n   explore a bit!");
scr_AddDialogLine(spr_signA, "* Signed,\n          -OTSR Corp.");
-convo_test_2:

Code:
active = true;
convoIndex = 0;

scr_AddDialogLine(spr_signA, "* This is a weird way to make textboxes\n  but, whatever");
scr_AddDialogLine(spr_signA, "* BUT THE THING.");
scr_AddDialogLine(spr_playerB, "* THAT PISSES ME OFF!");
scr_AddDialogLine(spr_playerB, "* IS HAVING TO WRITE SO MUCH CODE");

Here is the problem I am having:


I appreciate any help you can give me to solve this, as I can´t continue with my project and I've been trying to fix this since yesterday.
Thanks!
-OTT
 
Last edited by a moderator:
Top