A
Agletsio
Guest
What I'm trying to do is simply: Let the portrait change whenever the sentence has reached its end and I press "Z".
Initially when I pressed Z, even before the sentence finished, the portraits would change before the sentence was finished.
if keyboard_check_pressed(ord("Z")) {
por_current += 1;
}
So I added the (characters = message_lengh) as extra argument but now the portrait doesn't change until the entire conversation is finished.
if keyboard_check_pressed(ord("Z")) && (characters = message_length) {
por_current += 1;
}
Tried a few different variations of this but can't figure out the problem. Any help or guidance would seriously be appreciated!
Create Event:
Step Event
Draw Event
Initially when I pressed Z, even before the sentence finished, the portraits would change before the sentence was finished.
if keyboard_check_pressed(ord("Z")) {
por_current += 1;
}
So I added the (characters = message_lengh) as extra argument but now the portrait doesn't change until the entire conversation is finished.
if keyboard_check_pressed(ord("Z")) && (characters = message_length) {
por_current += 1;
}
Tried a few different variations of this but can't figure out the problem. Any help or guidance would seriously be appreciated!
Create Event:
Code:
//Typewriter effect
anim_done = false;
iswriting = false;
message[0] = "Hello"
message[1] = "Hello?"
message[2] = "How are you?"
message[3] = "...who are you?"
message[4] = "If only you knew..."
message[5] = "Knew what?"
message[6] = ""
message_current = 0;
message_end = 6;
message_draw = "";
increase = 0.37;
characters = 0;
hold = 0;
message_length = string_length(message[message_current]);
//Portraits
por_current = 0;
por[0] = spr_por_1
por[1] = spr_por_2
por[2] = spr_por_2
por[3] = spr_por_1
por[4] = spr_por_2
por[5] = spr_por_1
por[6] = ""
Code:
if (characters < message_length) { //if current character count is less than the amount in current message*
hold = keyboard_check(ord("Z")); //hold is true or false if we hold 'Z' or not
characters += increase * (1 + hold); //increase speed based on hold
message_draw = string_copy(message[message_current], 0, characters); //copy string to current character
}
else
{ //if current character is more than the amount in the current message
if (keyboard_check_pressed(ord("Z"))) { //if we press Z...
if (message_current < message_end) { //if there are more messages left to show (0 -> 6, in our case)
message_current += 1; //increase the message by 1
message_length = string_length(message[message_current]); //get the new character length for message
characters = 0; //set the characters back to 0
message_draw = ""; //clear the drawn text
}
else { //if our messages are done (we reach 6, in our case)...
if message_current = 6 {iswriting = false;} //destroy the object
}
}
}
if keyboard_check_pressed(ord("Z")) && (characters >= message_length) /*(characters = message_length)*/ {
por_current += 1;
}
if por_current > 5 {
iswriting = false;
}
Code:
if iswriting = true {
draw_set_font(font0);
draw_set_halign(fa_left)
draw_text(320,835, message_draw); //draw the text at the coordinates
}
if iswriting = true {
draw_sprite(por[por_current],0,190,890)
}
if anim_done = true {
draw_sprite(sprite0,0,1398,667)
}