A
AndHeDrew
Guest
Hello! I've been scratching my head about this, and would be very grateful for help!
I've been adding character textboxes to my game, and the first time I activate a textbox, the words are pushed farther down the box then they're supposed to be. (The X alignment is fine, it's the Y alignment that's off.)
This is just the first time I activate ANY textbox after starting the game, not EACH textbox. If I go back to the same character and talk to them again, it's fine. It only happens once each time I run the game, then everything is normal.
First time:
Every time after:
Here's what I've done:
---
Version: 2.1.3.273
Object: o_textbox
o_textbox: Create
o_textbox: Step
o_textbox: draw
Object: o_parent_talker (the parent object for talking characters)
o_parent_talker: create
o_parent_talker: step
o_parent_talker: alarm 1
Object: o_mother (the child object, a talking character)
o_mother: create
Deeply grateful for any assistance!
I've been adding character textboxes to my game, and the first time I activate a textbox, the words are pushed farther down the box then they're supposed to be. (The X alignment is fine, it's the Y alignment that's off.)
This is just the first time I activate ANY textbox after starting the game, not EACH textbox. If I go back to the same character and talk to them again, it's fine. It only happens once each time I run the game, then everything is normal.
First time:
Every time after:
Here's what I've done:
---
Version: 2.1.3.273
Object: o_textbox
o_textbox: Create
Code:
text_ = "text"
page_ = 0;
xBuffer_ = 10;
yBuffer_ = 10;
boxHeight_ = sprite_get_height(s_textbox);
boxWidth_ = sprite_get_width(s_textbox);
stringHeight_ = string_height(text_);
creator = noone;
charCount_ = 0;
name_ = noone;
Code:
if(keyboard_check_pressed(vk_space)) {
if(charCount_ < string_length(text_[page_])) {
charCount_ = string_length(text_[page_])
}
else if(page_+1 < array_length_1d(text_)){
page_ += 1;
charCount_ = 0;
} else{
instance_destroy();
creator.alarm[1] = 1;
}
}
Code:
//draw textbox
draw_rectangle(x-2, y-2, x+boxWidth_+2, y+boxHeight_+2, false);
draw_sprite(s_textbox, 0, x, y);
//set font
draw_set_font(f_text);
//incriment character counter every frame
if (charCount_ < string_length(text_[page_])) {
charCount_ += 1;
}
//copy part of the text
textPart_ = string_copy(text_[page_], 1, charCount_);
//Draw the name
draw_set_color(c_orange);
draw_set_halign(fa_center);
draw_text(x+boxWidth_/2, y+yBuffer_/2, name_);
draw_set_halign(fa_left);
//Draw Part of the Text
draw_set_color(c_white);
draw_text_ext(x+xBuffer_, y+stringHeight_+yBuffer_, textPart_, stringHeight_, boxWidth_ - (2*xBuffer_));
o_parent_talker: create
Code:
myTextbox_ = noone;
myName_ = "";
myText_[0] = "";
Code:
/// @description Insert description here
if(place_meeting(x,y, o_player)) {
//if I haven't created my textbox, create one.
if(keyboard_check_pressed(vk_space)){
if(myTextbox_ == noone){
myTextbox_ = instance_create_layer(x,y, "Text", o_textbox);
myTextbox_.text_ = myText_;
myTextbox_.creator = self;
myTextbox_.name_ = myName_;
}
}
} else {
if(myTextbox_ != noone){
instance_destroy(myTextbox_);
myTextbox_ = noone;
}
}
Code:
myTextbox_ = noone;
Object: o_mother (the child object, a talking character)
o_mother: create
Code:
event_inherited();
myName_ = "Mom";
myText_[0] = "Hello, dear!";
myText_[1] = "I'm so proud of you. I'm sure you'll do your best today.";
Deeply grateful for any assistance!