S
samyak
Guest
How to attach sound with text like in 0:10 in this video?
I'm using string_copy(string_xyz, 1, i ) and incrementing i+=0.4;
I'm using string_copy(string_xyz, 1, i ) and incrementing i+=0.4;
if( text_is_not_done ) {
i += 4;
audio_play_sound( snd_textbox_male );
}
What is "text_is_not_done"? How do I know that?The moment you increment "i", just play a sound?
Code:if( text_is_not_done ) { i += 4; audio_play_sound( snd_textbox_male ); }
What is "text_is_not_done"? How do I know that?
I had put this in the step event of the dialogue object-->
print=string_copy(str[next],1,i);
if i<=string_length(str[next]){ if i mod 1=0 and i mod 1<0.2 and string_char_at(str[next],i)!=" " {audio_play_sound(sound,1,false);} i+=0.2;}
next=clamp(next,0,3);
if next=0 and o_player.flip { instance_create_layer(x,y,1,o_another_object);i=0;}
if distance_to_object(o_player)<65 and o_player.flip and next>0 and next< 3
{
next++; i=0;
}
////////////////////////////////
But this does not work properly.
// Create Event
text = "this is what I want to say";
print = "";
text_delay = 30; // Bigger value = slower text
text_timer = current_time+text_delay;
text_sound = snd_text_male;
// Step Event
if( current_time >= text_timer ) {
if( string_length( print ) < string_length( text ) ) {
print = string_copy( text, 1, string_length( print )+1 );
audio_play_sound( text_sound, 1, false );
text_timer += text_delay;
}
}
// Draw Event
draw_text( x, y, print );
I will try your method soon. Thanks-
First of all, you are dealing with CHARACTERS, why use a FLOAT value ?
It doesn`t make sense.
I usually use my own timing system for situations like this:
The above uses a millisecond-based value ( internal variable current_time ).Code:// Create Event text = "this is what I want to say"; print = ""; text_delay = 30; // Bigger value = slower text text_timer = current_time+text_delay; text_sound = snd_text_male; // Step Event if( current_time >= text_timer ) { if( string_length( print ) < string_length( text ) ) { print = string_copy( text, 1, string_length( print )+1 ); audio_play_sound( text_sound, 1, false ); text_timer += text_delay; } } // Draw Event draw_text( x, y, print );
There is about 33 milliseconds per step in gamemaker, so you can be 30 time more precise using those
The "text_is_not_done" was just an indicator to show you that you need a condition to check before playing the sound otherwise the sound will play even if the text is done being shown.
That thing I've already achieved partially. I mean it worked sometime and did not work some other time, hence the problem.I want to add one thing to that, which is you should add a check for the character, and only play the sound if it is not a space. Then the sound will reflect the length of the words/pace of the text. I think that usually sounds better, as apposed to playing it every time.
Otherwise, that's pretty much what I do. Good luck.
wrote ->I want to add one thing to that, which is you should add a check for the character, and only play the sound if it is not a space. Then the sound will reflect the length of the words/pace of the text. I think that usually sounds better, as apposed to playing it every time.
Otherwise, that's pretty much what I do. Good luck.
I tried your method. But there was sound even if there was Space.-
First of all, you are dealing with CHARACTERS, why use a FLOAT value ?
It doesn`t make sense.
I usually use my own timing system for situations like this:
The above uses a millisecond-based value ( internal variable current_time ).Code:// Create Event text = "this is what I want to say"; print = ""; text_delay = 30; // Bigger value = slower text text_timer = current_time+text_delay; text_sound = snd_text_male; // Step Event if( current_time >= text_timer ) { if( string_length( print ) < string_length( text ) ) { print = string_copy( text, 1, string_length( print )+1 ); audio_play_sound( text_sound, 1, false ); text_timer += text_delay; } } // Draw Event draw_text( x, y, print );
There is about 33 milliseconds per step in gamemaker, so you can be 30 time more precise using those
The "text_is_not_done" was just an indicator to show you that you need a condition to check before playing the sound otherwise the sound will play even if the text is done being shown.
I had wriitenprint, based on your code, is the entire string, not just the last character. You have to put print into string_char_at to find the last character (the most recent one that was added to the string) to see if that one is a space. As it is it is basically never going to be equal to space.