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.
Thanks.whenspacekey pressedsetPlayingMusicto1play soundGuitarChords1forever ifPlayingMusic=1switch to costumeballerina-bwait0.1secsswitch to costumeballerina-cwait0.1secsswitch to costumeballerina-bwait0.1secsswitch to costumeballerina-asetPlayingMusicto0
Offline
Just do this:
whenspace ▼key pressedplay soundGuitarChords1 ▼switch to costumeballerina-b ▼wait0.1secsswitch to costumeballerina-c ▼wait0.1secsswitch to costumeballerina-b ▼wait0.1secsswitch to costumeballerina-a ▼
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.Thanks.whenspacekey pressedsetPlayingMusicto1play soundGuitarChords1forever ifPlayingMusic=1switch to costumeballerina-bwait0.1secsswitch to costumeballerina-cwait0.1secsswitch to costumeballerina-bwait0.1secsswitch to costumeballerina-asetPlayingMusicto0
The problem is that the forever if block checks the condition (if playingmusic=1) once, and then if true, will repeat forever. Try:
Foreverifplayingmusic=1do 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.Thanks.whenspacekey pressedsetPlayingMusicto1play soundGuitarChords1forever ifPlayingMusic=1switch to costumeballerina-bwait0.1secsswitch to costumeballerina-cwait0.1secsswitch to costumeballerina-bwait0.1secsswitch to costumeballerina-asetPlayingMusicto0The problem is that the forever if block checks the condition (if playingmusic=1) once, and then if true, will repeat forever. Try:
Foreverifplayingmusic=1do 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
whenclicked
or whatever starts the animationforeverifplay sounds=1play soundmusic ▼whenclicked
setplay music ▼to1animationsetplay music ▼to0stop all pinkssounds
Last edited by zammer990 (2012-08-26 10:40:36)
Offline