Trigger sounds during specific frames of an animation???
bluelotus
Member Posts: 96
Is there a way to trigger sounds during specific frames of an animation? Lets say I have a 90 frame animation (@ 30fps) and I want to trigger a sound at 2 seconds. I tried setting a rule: when self.image is 60.png ---> play sound
but that doesn't do anything
Any thoughts? Thanks!
but that doesn't do anything
Any thoughts? Thanks!
Comments
After 2 seconds, call the sound.
The issue is that currently the animation is running slower on my iphone 2g than on a 3g or the simulator. When I use a timer for the sounds the sync is all off.
I am running two animations at once and a few sounds so do you think that if I condense the animations down to 1 single animation it might run a little faster?
Also, Is there potential issues with too many sounds playing at once?
You have to think of the RAM usage. What does the RAM usage say when you test it with the GS Viewer?
Somewhere around 45MB of RAM usage, an older iPhone will crash.
Regardless of how small the file sizes of those images are, the RAM usage will be fixed.
It is easy enough to calculate how much RAM you are using:
Each pixel in each image is 24-bit, or 3 bytes.
Let's say you have a 480x320 image.
Simply multiply 480 x 320 x 3 to get the amount of memory needed to display that image.
480 x 320 x 3 = 460,800 = ~460K
So one full screen iPhone image requires about 460K. Again, this is independent of the file size that you saved the image. You might have been able to save the image down to 17K - it still requires 460K of RAM to display.
Now, if you have 90 frames of an animation that are all full screen like that, simply multiply
460,800 x 90. That will get you 41,472,000, or about 41MB.
You also have to leave room for the GS engine, plus all the sounds, actors, Rules, etc. in your game.
You will quickly bypass the RAM usage threshold just with one animation.
I assume your animation is not full-screen, but just use the above formula to see how much RAM it uses. Better yet, use the GS Viewer to watch the RAM as you play your game. As the RAM starts climbing into the 40MB region, you're starting to enter the danger zone.
Image sequence animations at 30 FPS are really wishful thinking. They will play fine one your computer in Preview because you have tons of RAM to play with, but the memory on the devices is severely limited.
And if you have multiple animations, they all add up.
Try using the Interpolate behavior to slide things around, fade things up and down, things like that. Try to use Rules, behaviors, Timers, etc. to make your animations. That will save you precious RAM.
I'll optimize :P
:-)
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
I am running two animations at the same time. Each is about 90 frames @ 10fps. Then I have layered sounds over the animation set off with timers to go off sequentially at different times during the animation.
I think there is simply just to much going on at once. My plan at this point is to merge the two animations to 1 single animation and put all she sounds onto one audio track.... This is actually the way I had it before but the file size was just too big so thats why I tried to break it all up.
I guess I'll have to sacrifice overall file size for RAM....
THanks everyone for your input, Its always helps!!! The optimization continues....