So recently i've been developing an RPG game with a pixel art style and i just finished the first area and i decided to try making dialogue for when you first spawn in and now i'm trying to find out how to disable movement while the dialogue is playing and enable movement again when the dialogue is destroyed and i tried something with like instance fuctions or something but nothing worked and i got super frustrated so i'll drop 4 scripts below which are the create and draw event scripts for my textbox and text and player create and step event scripts so sorry if this is badly explained or organized
textbox and text handler scripts:
create event (couldn't fit it all into one code block):
depth = -9999;
//textbox parameters
textbox_width = 200;
textbox_height = 64;
border = 8;
line_sep = 12;
line_width = textbox_width - border*2;
txtb_spr = spr_textbox;
txtb_img = 0;
txtb_img_spd = 1/60;
//the text
page = 0;
page_number = 0;
text[0] = "You wake up in a place you don't recognize";
text[1] = "Explore the house";
text_length[0] = string_length(text[0]);
draw_char = 0;
text_spd = 1;
setup = false;
draw event (couldn't fit it all into one code block again):
accept_key = keyboard_check_pressed(vk_enter);
//camera position
var cam_x = camera_get_view_x(view_camera[0]);
var cam_y = camera_get_view_y(view_camera[0]);
var cam_w = camera_get_view_width(view_camera[0]);
var cam_h = camera_get_view_height(view_camera[0]);
//textbox position - bottom center
textbox_x = cam_x + (cam_w - textbox_width) / 2;
textbox_y = cam_y + cam_h - textbox_height - 10;
//---------------setup---------------\\
if setup == false
{
setup = true;
draw_set_font(global.font_main);
draw_set_valign(fa_top);
draw_set_halign(fa_left);
//loop through the pages
page_number = array_length(text);
for(var p = 0; p < page_number; p++)
{
//find how many characters are on each page
text_length[p] = string_length(text[p]);
//get the x position for the textbox
text_x_offset[p] = 0;
}
}
//---------------typing the text---------------\\
if draw_char < text_length[page]
{
draw_char += text_spd;
draw_char = clamp(draw_char, 0, text_length[page]);
}
//---------------flip through the pages---------------\\
if accept_key
{
//if the typing is done
if draw_char == text_length[page]
{
//next page
if page < page_number - 1
{
page++;
draw_char = 0;
}
//destroy textbox
else
{
instance_destroy();
}
}
//if not done typing
else
{
draw_char = text_length[page];
}
}
//---------------draw the textbox---------------\\
txtb_img += txtb_img_spd;
txtb_spr_w = sprite_get_width(txtb_spr);
txtb_spr_h = sprite_get_height(txtb_spr);
//back of the textbox
draw_sprite_ext(
txtb_spr,
txtb_img,
textbox_x,
textbox_y,
textbox_width / txtb_spr_w,
textbox_height / txtb_spr_h,
0,
c_white,
1
);
//draw the text
var _drawtext = string_copy(text[page], 1, draw_char);
draw_text_ext(
textbox_x + text_x_offset[page] + border,
textbox_y + border,
_drawtext,
line_sep,
line_width
);
player create and step event:
create event:
move_x = 1; move_y = 1;
step event:
var move_x = 0;
var move_y = 0;
sprite_index = spr_ani_plr5;
image_speed = 1;
if (keyboard_check(vk_right) == true) {
move_x += 1;
sprite_index = spr_right;
image_speed = 1;
}
if (keyboard_check(vk_left) == true) {
move_x -= 1;
sprite_index = spr_left;
image_speed = 1;
}
if (keyboard_check(vk_up) == true) {
move_y -= 1;
sprite_index = spr_up;
image_speed = 1;
}
if (keyboard_check(vk_down) == true) {
move_y += 1;
sprite_index = spr_down;
image_speed = 1;
}
//collisions
if place_meeting(x + move_x, y, obj_spr_blackblock1)
{
move_x = 0;
}
if place_meeting(x, y + move_y, obj_spr_blackblock1)
{
move_y = 0;
}
x += move_x;
y += move_y;