Hi,
I'm trying to animate a sprite while a sound is playing. I don't really want to have the loop hard coded because that would require a code change if the sound changes.
Below is the script so far but I know the reset of the PlayingMusic variable isn't right.
when (space) key pressed set (PlayingMusic) to [1] play sound (GuitarChords1) forever if <(PlayingMusic) = [1]> switch to costume (ballerina-b) wait [0.1] secs switch to costume (ballerina-c) wait [0.1] secs switch to costume (ballerina-b) wait [0.1] secs switch to costume (ballerina-a) set (PlayingMusic) to [0] endThanks.
Offline
Just do this:
when [space v] key pressed play sound [GuitarChords1 v] switch to costume [ballerina-b v] wait (0.1) secs switch to costume [ballerina-c v] wait (0.1) secs switch to costume [ballerina-b v] wait (0.1) secs switch to costume [ballerina-a v]
Offline
Teamwild wrote:
Hi,
I'm trying to animate a sprite while a sound is playing. I don't really want to have the loop hard coded because that would require a code change if the sound changes.
Below is the script so far but I know the reset of the PlayingMusic variable isn't right.when (space) key pressed set (PlayingMusic) to [1] play sound (GuitarChords1) forever if <(PlayingMusic) = [1]> switch to costume (ballerina-b) wait [0.1] secs switch to costume (ballerina-c) wait [0.1] secs switch to costume (ballerina-b) wait [0.1] secs switch to costume (ballerina-a) set (PlayingMusic) to [0] endThanks.
The problem is that the forever if block checks the condition (if playingmusic=1) once, and then if true, will repeat forever. Try:
Forever if (playingmusic=1) do rest of code
Offline
TheScratchChatter wrote:
Teamwild wrote:
Hi,
I'm trying to animate a sprite while a sound is playing. I don't really want to have the loop hard coded because that would require a code change if the sound changes.
Below is the script so far but I know the reset of the PlayingMusic variable isn't right.when (space) key pressed set (PlayingMusic) to [1] play sound (GuitarChords1) forever if <(PlayingMusic) = [1]> switch to costume (ballerina-b) wait [0.1] secs switch to costume (ballerina-c) wait [0.1] secs switch to costume (ballerina-b) wait [0.1] secs switch to costume (ballerina-a) set (PlayingMusic) to [0] endThanks.The problem is that the forever if block checks the condition (if playingmusic=1) once, and then if true, will repeat forever. Try:
Forever if (playingmusic=1) do rest of code
A common misconception, it actually does the exact same thing.
If the sound is the same length as the animation, then you can just use BirdByte's script
Offline
zammer990 wrote:
A common misconception, it actually does the exact same thing.
If the sound is the same length as the animation, then you can just use BirdByte's script
^^^ This.
If the sound is not the same length, and you want it to be, then time the changing of the costumes differently.
Offline
henley wrote:
zammer990 wrote:
A common misconception, it actually does the exact same thing.
If the sound is the same length as the animation, then you can just use BirdByte's script^^^ This.
If the sound is not the same length, and you want it to be, then time the changing of the costumes differently.
Or, you could do this
when gf clicked// or whatever starts the animation forever if <(play sounds) = (1)> play sound [music v] end when gf clicked set [play music v] to (1) animation set [play music v] to (0) stop all pinks//sounds
Last edited by zammer990 (2012-08-26 10:40:36)
Offline