J
Jestermask
Guest
So I almost did it, but not quite...
When Object_Player collides with oCharacter the text in the textbox is "stretched" like in the first pictue: http://imgur.com/a/OC93i ...Although it's as it should be every other time the player collides with the character again, the 1st time is always wrong... Probably some dumb mistake like always, but I can't figure it out this time... I would appreciate any help!
Here's the code:
oTextbox
CREATE
text = "object text"
boxwidth = sprite_get_width(textbox);
stringheight = string_height(text);
DRAW
//draw textbox
draw_sprite(textbox, 0, x - sprite_get_width(textbox)/2, y)
//draw text
draw_set_font(Gothic_Font)
draw_text_ext(x - sprite_get_width(textbox)/2, y, text, stringheight, boxwidth)
oCharacter
CREATE
mytext = "Hello!"
mytextbox = noone
STEP
if (place_meeting(x, y, Object_Player))
{
if (mytextbox == noone)
{
mytextbox = instance_create_layer(x, y, "text_layer", Object_Textbox);
mytextbox.text = mytext;
}
} else{
if (mytextbox != noone)
{
instance_destroy(mytextbox);
mytextbox = noone;
}
}
When Object_Player collides with oCharacter the text in the textbox is "stretched" like in the first pictue: http://imgur.com/a/OC93i ...Although it's as it should be every other time the player collides with the character again, the 1st time is always wrong... Probably some dumb mistake like always, but I can't figure it out this time... I would appreciate any help!
Here's the code:
oTextbox
CREATE
text = "object text"
boxwidth = sprite_get_width(textbox);
stringheight = string_height(text);
DRAW
//draw textbox
draw_sprite(textbox, 0, x - sprite_get_width(textbox)/2, y)
//draw text
draw_set_font(Gothic_Font)
draw_text_ext(x - sprite_get_width(textbox)/2, y, text, stringheight, boxwidth)
oCharacter
CREATE
mytext = "Hello!"
mytextbox = noone
STEP
if (place_meeting(x, y, Object_Player))
{
if (mytextbox == noone)
{
mytextbox = instance_create_layer(x, y, "text_layer", Object_Textbox);
mytextbox.text = mytext;
}
} else{
if (mytextbox != noone)
{
instance_destroy(mytextbox);
mytextbox = noone;
}
}