Imiglikos
Member
Hi,
I have a friend in the game that the player is talking to. It works like this, the player will be within the friend's range (range <100), then press enter and a dialogue will start.
and it all works fine ..distance_to_object() and should take it into account as well as in the case of handling a keyboard key
I am asking you for help, thank you
this is my correct code ..
obj_dialogbox_friend
create
step
and here now, when I add support for the gamepad key, there is this problem as i described above ..
I have a friend in the game that the player is talking to. It works like this, the player will be within the friend's range (range <100), then press enter and a dialogue will start.
and it all works fine ..distance_to_object() and should take it into account as well as in the case of handling a keyboard key
I am asking you for help, thank you
this is my correct code ..
obj_dialogbox_friend
create
GML:
speak = false;
image_speed = 1;
step
GML:
if instance_exists(obj_hero)
if (!instance_exists(obj_box)) {
if (!obj_hero.inAir) && (!place_meeting(x, y, obj_hero)) {
if (distance_to_object(obj_hero) < 100) && (keyboard_check_pressed(vk_enter)) ; {
speak = true;
dialogue_inst = instance_create(0, 0, obj_box);
with (dialogue_inst) {
text[0] = ("Hi how are you");
avatar[0] = true;
avatarSprite[0] = spr_friend;
textColour[0] = c_black;
shadow[0] = true;
shadowWidth[0] = 4;
text[1] = gmt("I'm fine. And you?");
avatar[1] = true;
avatarSprite[1] = spr_hero;
textColour[1] = c_black;
shadow[1] = true;
shadowWidth[1] = 4;
text[2] = gmt("Okay too");
avatar[2] = true;
avatarSprite[2] = spr_friend;
textColour[2] = c_black;
shadow[2] = true;
shadowWidth[2] = 4;
curText = 0;
maxText = 2;
add_text(text[curText], avatar[curText],avatarSprite[curText],textColour[curText],shadow[curText], shadowWidth[curText]);
}
}
}
}
else {
if (obj_hero.x < x) {
image_xscale = -1;
}
else {
image_xscale = 1;
}
obj_hero.image_xscale = image_xscale * -1;
}
and here now, when I add support for the gamepad key, there is this problem as i described above ..
GML:
if (distance_to_object(obj_hero) < 100) && (keyboard_check_pressed(vk_enter)) || (gamepad_button_check_pressed(0,gp_shoulderr)); {
GML:
if instance_exists(obj_hero)
if (!instance_exists(obj_box)) {
if (!obj_hero.inAir) && (!place_meeting(x, y, obj_hero)) {
if (distance_to_object(obj_hero) < 100) && (keyboard_check_pressed(vk_enter)) || (gamepad_button_check_pressed(0,gp_shoulderr)); {
speak = true;
dialogue_inst = instance_create(0, 0, obj_box);
with (dialogue_inst) {
text[0] = ("Hi how are you");
avatar[0] = true;
avatarSprite[0] = spr_friend;
textColour[0] = c_black;
shadow[0] = true;
shadowWidth[0] = 4;
text[1] = gmt("I'm fine. And you?");
avatar[1] = true;
avatarSprite[1] = spr_hero;
textColour[1] = c_black;
shadow[1] = true;
shadowWidth[1] = 4;
text[2] = gmt("Okay too");
avatar[2] = true;
avatarSprite[2] = spr_friend;
textColour[2] = c_black;
shadow[2] = true;
shadowWidth[2] = 4;
curText = 0;
maxText = 2;
add_text(text[curText], avatar[curText],avatarSprite[curText],textColour[curText],shadow[curText], shadowWidth[curText]);
}
}
}
}
else {
if (obj_hero.x < x) {
image_xscale = -1;
}
else {
image_xscale = 1;
}
obj_hero.image_xscale = image_xscale * -1;
}
Last edited: