Saturday, June 19, 2021

【GAMEMAKER】multiple lines Typewriter

 Information about object: Typewriter

Sprite:
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask:
No Physics Object
Create Event:
execute code:

amounttyped = 0
text[1] = "hi"           //change this to the first line of text you want
text[2] = "bye"          //you can add more lines after this, increase the number for each line

text[3] = ""             //leave an extra line
text[4] = "lorem" 
texty = text[1]          //first line to read
line = 1                 //first line's number
maxlines = 4             //last line's number
alarm[0]= 30             //time between letters


Destroy Event:
execute code:

//in here, just put what should happen after it's done typing everything

game_end()
Alarm Event for alarm 0:
execute code:

amounttyped+=1
alarm[0]= 30             //amount of time between letters
if amounttyped = string_length(texty) {
 alarm[0]=60             //amount of time to linger on completed lines
}
if amounttyped > string_length(texty) {
 line = line + 1
 if line > maxlines {
  instance_destroy()

 }else{
 texty = text[line]
 }
 
 amounttyped = 0
}
Draw Event:
execute code:

draw_set_color(c_black)        //change to desired text color
draw_set_font(fnt_courier)      //change to desired font
draw_text(x,y,string_copy(texty,1,amounttyped))

No comments:

Post a Comment

End of Summer Sale ☀️😎

20% OFF Inside!🤯 ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏  ͏...