Dialogue sound

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;
 
C

CedSharp

Guest
The moment you increment "i", just play a sound?

Code:
if( text_is_not_done ) {
    i += 4;
    audio_play_sound( snd_textbox_male );
}
 
S

samyak

Guest
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.
 
C

CedSharp

Guest
-
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.

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:
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 );
The above uses a millisecond-based value ( internal variable current_time ).
There is about 33 milliseconds per step in gamemaker, so you can be 30 time more precise using those :D
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.
 
S

samyak

Guest
I
-


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:
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 );
The above uses a millisecond-based value ( internal variable current_time ).
There is about 33 milliseconds per step in gamemaker, so you can be 30 time more precise using those :D
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 will try your method soon. Thanks
 
Last edited by a moderator:
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.
 
S

samyak

Guest
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.
That thing I've already achieved partially. I mean it worked sometime and did not work some other time, hence the problem.
 
S

samyak

Guest
I
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 ->
if print!=" " { audio_play_sound( text_sound, 1, false );

but it did not work....
 
S

samyak

Guest
-


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:
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 );
The above uses a millisecond-based value ( internal variable current_time ).
There is about 33 milliseconds per step in gamemaker, so you can be 30 time more precise using those :D
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 tried your method. But there was sound even if there was Space.
 
S

samyak

Guest
At first it worked, then after sometime somehow it did not work.
 
Last edited by a moderator:
print, 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.
 
S

samyak

Guest
print, 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.
I had wriiten
if (string_char_at(str[next],string_length( print ))!=" " or string_char_at(str[next],string_length( print ))!=",") {}
instead of
if (string_char_at(str[next],string_length( print ))!=" " and string_char_at(str[next],string_length( print ))!=",") {

That was the problem.

But I have a new problem. New str[next] is not draw when next changes from 0 to 1 (for new sentence). I have to figure it out.
 
Top