• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GML Help with typewriter effect bug, please!

E

Edwin

Guest
Hey, people. I have a simple typewriter effect for my text but it's lagging after the line break. How I can fix it?
Code:
Code:
/// Create Event
message = "Hello, World! This is my typewriter effect test!";
count = 0;

// Step Event
if (count < string_length(message)) {
    count ++;
}

// Draw Event
draw_text_ext(x, y, string_copy(message, 0, count), 20, 200);
So all I know it's happening because the width of draw_text_ext is not proportional to the room size. How can I fix it?
 
I would do it this way:

Code:
// Create Event
message = "Hello, World! This is my typewriter effect test!";
message_final = "";
count = 1;
type_delay = room_speed/4;
alarm[0] = type_delay;

// Alarm 0 Event
if (string_length(message_final) < string_length(message)) {
   // Get the char at count index
   var char = string_char_at(message, count);

  // Add the char to the final message
  message_final += char;

   // Increment count
   count++;

   // Reset the alarm
   alarm[0] = type_delay;
}


// Draw Event
draw_text(x, y, message_final);
 
E

Edwin

Guest
I would do it this way:

Code:
// Create Event
message = "Hello, World! This is my typewriter effect test!";
message_final = "";
count = 1;
type_delay = room_speed/4;
alarm[0] = type_delay;

// Alarm 0 Event
if (string_length(message_final) < string_length(message)) {
   // Get the char at count index
   var char = string_char_at(message, count);

  // Add the char to the final message
  message_final += char;

   // Increment count
   count++;

   // Reset the alarm
   alarm[0] = type_delay;
}


// Draw Event
draw_text(x, y, message_final);
I think you didn't understand my question, but thanks for this example.
 

3dgeminis

Member
It is normal, if while writing a word and this is passed the limit, this goes to the next line.
What you can do is separate the line breaks beforehand
Code:
message = "Hello, World! This is my#typewriter effect test!" ///use # to separate
or
Code:
message = "Hello, World! This is my
typewriter effect test!"
 
Top