E
Eclectia
Guest
I'm working on textboxes right now. This is the base code for the obj_textbox event that gets called:
//
page = 0;
text = "";
xBuffer = 10;
yBuffer = 10;
boxWidth = sprite_get_width(Textbox);
boxHeight = string_height(text);
creator = noone;
name = noone;
draw_sprite(Textbox, 0, x, y);
draw_set_font(fnt_text);
draw_set_halign(fa_center);
draw_text (x+(boxWidth/2), y+yBuffer, name);
draw_set_halign(fa_left);
draw_text_ext (x+xBuffer, y+yBuffer, text[page], boxHeight, boxWidth);
if (keyboard_check_pressed(vk_space)){
if (page+1 < array_length_1d(text)){
page +=1
} else {
instance_destroy();
creator.alarm[1] = 1;
}
}
//
And this is the object, with the text:
//
Textbox = noone;
myName = "Deer Warden";
myText [0] = "Testing! Does this string length wrap to the next line?";
myText [1] = "Still testing!";
myText [2] = "Bazinga";
if (place_meeting(x, y, obj_player)){
if (keyboard_check_pressed(vk_space)){
if myTextbox == noone{
myTextbox = instance_create_layer(x, y, "text", obj_textbox);
myTextbox.text = myText;
myTextbox.creator = self;
myTextbox.name = myName;
}
}
} else {
if (myTextbox != noone){
instance_destroy(myTextbox);
myTextbox = noone;
}
}
//
This was working fine, wrapping and all until I implemented this change, because I wanted the textbox to pop up underneath the character rather than adjacent to them and was doing this manually:
//
draw_sprite(Textbox, 0, x-200, y+100);
draw_set_font(fnt_text);
draw_set_halign(fa_center);
draw_text (x-200+(boxWidth/2), y+90+yBuffer, name);
draw_set_halign(fa_left);
draw_text_ext (x-200+xBuffer, y+110+yBuffer, text[page], boxHeight, boxWidth-yBuffer);
//
For some reason, when I made the above changes to the base code, the wrapping doesn't work. I've tried a few variations on this code and nothing's worked. Any suggestions or advice would be appreciated - I hope I've described this alright.
//
page = 0;
text = "";
xBuffer = 10;
yBuffer = 10;
boxWidth = sprite_get_width(Textbox);
boxHeight = string_height(text);
creator = noone;
name = noone;
draw_sprite(Textbox, 0, x, y);
draw_set_font(fnt_text);
draw_set_halign(fa_center);
draw_text (x+(boxWidth/2), y+yBuffer, name);
draw_set_halign(fa_left);
draw_text_ext (x+xBuffer, y+yBuffer, text[page], boxHeight, boxWidth);
if (keyboard_check_pressed(vk_space)){
if (page+1 < array_length_1d(text)){
page +=1
} else {
instance_destroy();
creator.alarm[1] = 1;
}
}
//
And this is the object, with the text:
//
Textbox = noone;
myName = "Deer Warden";
myText [0] = "Testing! Does this string length wrap to the next line?";
myText [1] = "Still testing!";
myText [2] = "Bazinga";
if (place_meeting(x, y, obj_player)){
if (keyboard_check_pressed(vk_space)){
if myTextbox == noone{
myTextbox = instance_create_layer(x, y, "text", obj_textbox);
myTextbox.text = myText;
myTextbox.creator = self;
myTextbox.name = myName;
}
}
} else {
if (myTextbox != noone){
instance_destroy(myTextbox);
myTextbox = noone;
}
}
//
This was working fine, wrapping and all until I implemented this change, because I wanted the textbox to pop up underneath the character rather than adjacent to them and was doing this manually:
//
draw_sprite(Textbox, 0, x-200, y+100);
draw_set_font(fnt_text);
draw_set_halign(fa_center);
draw_text (x-200+(boxWidth/2), y+90+yBuffer, name);
draw_set_halign(fa_left);
draw_text_ext (x-200+xBuffer, y+110+yBuffer, text[page], boxHeight, boxWidth-yBuffer);
//
For some reason, when I made the above changes to the base code, the wrapping doesn't work. I've tried a few variations on this code and nothing's worked. Any suggestions or advice would be appreciated - I hope I've described this alright.