GameMaker Speeding up typewriter text effect only when key is pressed

F

Falconsoft-Industries

Guest
Here’s my draw event code
draw_sprite(self.x+4,self.y+4,spr_message_box)
If !keyboard_check_pressed(vk_space)
{
draw_text(x,y,draw_copy_string(sentences,1,index))
// 1 is how many characters a second are typed
}
If keyboard_check_pressed(vk_space)
{
draw_text(x,y,draw_copy_string(sentences,10,index))
// 10 is how many characters a second are typed
}
Will this work?, ‘I know all my other code to handle loops for the typewriter text effect work.’
 
Last edited by a moderator:
W

Wraithious

Guest
It looks like that should work, the best thing to do would be to test it, if it doesnt work post the code block that determines how many characters are typed in a time range and we can see if theres an error there or if it just needs to be modifyed to be made more dynamic.
 

Kyon

Member
We have no idea what draw_copy_string() does so we wouldn't know.
Simply testing it would work though.

Anyway, I have my own method for typewriter-like text with a way to speed it up, if you need any help just ask :)
 
F

Falconsoft-Industries

Guest
Thanks that would be great if my solution does not work I will ask you for help... :)
 
Instead of asking whether it will work, why not test it out first? Then you would have discovered that it would only work for a single frame.
 
draw_sprite(self.x+4,self.y+4,spr_message_box)
Will this work?
Your typewriter effect might, but your sprite drawing won't.
You really need to read up on how to use the draw_sprite function as this is now the second topic where you have posted the incorrect syntax of that function.

From the manual:
Code:
draw_sprite(sprite, subimg, x, y);
What you tried to do:
Code:
draw_sprite(x, y, sprite)
 
W

Wraithious

Guest
Your typewriter effect might, but your sprite drawing won't.
You really need to read up on how to use the draw_sprite function as this is now the second topic where you have posted the incorrect syntax of that function.

From the manual:
Code:
draw_sprite(sprite, subimg, x, y);
What you tried to do:
Code:
draw_sprite(x, y, sprite)
I totally missed that, I was focused on the typewriter script part, yea that code would definatly crash the game on the first draw step it's executed in.
 
F

Falconsoft-Industries

Guest
Yeah okay I have tried this method but it does not work, also I need help with setting a timeline in gml, for a path for a cutscene object because doing it with direction and speed and image_index changing on collision with non viewable trigger objects only worked once and I need them to be viewable but with image_alpha=0 and when I attempted the paths resource tree it only makes it worst and harder to use, so I am timing the movement patterns I need now, using a timeline resource.
 

TheouAegis

Member
Your code, if anything, should draw 10 letters at a time every single time you press the spacebar, otherwise it will display one at a time. But you have to keep tapping the space bar. either use a normal keyboard_check() call or use a variable to track when the current dialogue needs to be sped up (and clear the variable at the end of the dialogue).
 
F

Falconsoft-Industries

Guest
Ah thanks I will give that a try.
Yes it works thank you...
 
Last edited by a moderator:
F

Falconsoft-Industries

Guest
hmmmmm... the new problem is that it replaces the text with the first 10 letters where the start of the first line of text is including adding the typed out text already typed. how to fix?
Ah I see the solution now all I really needed is this code after drawing the the message box and text, the solution is as follows

if keyboard_check(vk_space)
{
index++
}
 
Last edited by a moderator:
Top