Synchronizing sound with animation
I have a (maybe not quite so) advanced scripting question: Is it possible to "attach" a sound effect with a frame in an animation, for example, everytime frame 3 in an animation occurs, a sound effect plays?
As it is now, I'm working with wait commands, which is highly unideal. Any help?
As it is now, I'm working with wait commands, which is highly unideal. Any help?
You know how the 'hit' sound of fists and sword is done? You could try to copy that. It involves setting SPECIAL frames in dink.ini, and sp_attack_hit_sound(&spritenum, &soundnum);
Now you just have to make it 'hit' something.
But beware: ALL sprites with that sequence will play that sound if there's something they 'hit' (i.e. when there's another hittable sprite in their hardbox).
Now you just have to make it 'hit' something.
But beware: ALL sprites with that sequence will play that sound if there's something they 'hit' (i.e. when there's another hittable sprite in their hardbox).
It seems quite easy. I may be wrong though.
Why don't you try looking at the frame delay for a sprite. Let's say it's 33 milliseconds and you want the sound to play on every 3rd frame. Then you would just type:
...
wait(99)
playsound(...);
wait(99)
playsound(...);
and continue that over and over. Or you could do something like this:
...
loop:
wait(99)
playsound(...);
wait(99)
playsound(...);
goto loop;
Is this what you wanted?
Why don't you try looking at the frame delay for a sprite. Let's say it's 33 milliseconds and you want the sound to play on every 3rd frame. Then you would just type:
...
wait(99)
playsound(...);
wait(99)
playsound(...);
and continue that over and over. Or you could do something like this:
...
loop:
wait(99)
playsound(...);
wait(99)
playsound(...);
goto loop;
Is this what you wanted?
"As it is now, I'm working with wait commands, which is highly unideal. Any help?"
"Why don't you try looking at the frame delay for a sprite. Let's say it's 33 milliseconds and you want the sound to play on every 3rd frame
...
wait(99)"
He does NOT want to use wait() commands, he wants to go AWAY from wait commands. Besides, this:
loop:
wait(99)
playsound(...);
goto loop;
would be enough if he did want that.
"Why don't you try looking at the frame delay for a sprite. Let's say it's 33 milliseconds and you want the sound to play on every 3rd frame
...
wait(99)"
He does NOT want to use wait() commands, he wants to go AWAY from wait commands. Besides, this:
loop:
wait(99)
playsound(...);
goto loop;
would be enough if he did want that.
Thanks for the replies. I'm afraid your's doesn't work for me Magicman. I need this for a brain 6 script, so it's just a "static" sprite with a repeated animation.
It works using waits like Dinkdude says, but the waits differ from computer to computer, so on computer 1 it can be all good, but on computer 2 the sound is way off. When the cpu is under load, the sound can also delay.
So, any more ideas?
It works using waits like Dinkdude says, but the waits differ from computer to computer, so on computer 1 it can be all good, but on computer 2 the sound is way off. When the cpu is under load, the sound can also delay.
So, any more ideas?
Well, that's a pity. I don't think there's any way to do it other than the wait commands.
Anyway, if you do figure out some way to make it work, I'm guessing this is gonna be one good D-MOD!
Anyway, if you do figure out some way to make it work, I'm guessing this is gonna be one good D-MOD!
No I'm pretty sure it is possible. And actually, the D-mod I'm making is going to be somewhat mediocre.
Since it's a static animation, you could do the whole thing manually, ie:
animate:
wait(50);
sp_pframe(¤t_sprite,2);
wait(50);
sp_pframe(¤t_sprite,3);
playsound(13,22050,0,¤t_sprite,0);
wait(50);
sp_pframe(¤t_sprite,4);
wait(50);
sp_pframe(¤t_sprite,5);
wait(50);
sp_pframe(¤t_sprite,1);
goto animate;
animate:
wait(50);
sp_pframe(¤t_sprite,2);
wait(50);
sp_pframe(¤t_sprite,3);
playsound(13,22050,0,¤t_sprite,0);
wait(50);
sp_pframe(¤t_sprite,4);
wait(50);
sp_pframe(¤t_sprite,5);
wait(50);
sp_pframe(¤t_sprite,1);
goto animate;
That was more along the lines I was thinking, thanks.
EDIT: had some rambling about it not working right, but that was due to my stupidness. I forgot to remove the brain 6. So yeah, it's working splendidly. A kazillion thanks peoples!
Everybody to the limit.
EDIT: had some rambling about it not working right, but that was due to my stupidness. I forgot to remove the brain 6. So yeah, it's working splendidly. A kazillion thanks peoples!
Everybody to the limit.