Trigger sounds during specific frames of an animation???

bluelotusbluelotus Member Posts: 96
edited November -1 in Working with GS (Mac)
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!

Comments

  • firemaplegamesfiremaplegames Member Posts: 3,211
    You'll need to user a Timer.

    After 2 seconds, call the sound.
  • bluelotusbluelotus Member Posts: 96
    Thanks firemaple. I was trying to avoid that :(
    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?
  • firemaplegamesfiremaplegames Member Posts: 3,211
    Well, a 90-frame animation is really heavy...

    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.
  • bluelotusbluelotus Member Posts: 96
    wow, thank you! you seriously rock!

    I'll optimize :P
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    firemaplegames said:
    Well, a 90-frame animation is really heavy...

    Image sequence animations at 30 FPS are really wishful thinking.

    I reckon, bluelotus, if you cut out every other frame, to make your animation 15fps, you won't see any difference at all from this, compared with 30. I betcha...

    :-)

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • bluelotusbluelotus Member Posts: 96
    Thanks gyro... when I posted this I just used the 30fps as an example. Maybe I should have been more specific to this actual project :P

    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....
Sign In or Register to comment.