audio droping fps and animation problem

audio droping fps and animation problem
0.0 0



In the game i’m making i have an 8-direction pad and a main character that runs controlled by it. Actually, i’m drawing in a CCLayerColor the main character with some animations, the fps data provided by cocos2d-x, a layer with the control and a layer with physics debug. The physics are implemented with box2d and have fixed timestep. Drawing all this, the game runs stable between 57-59 fps. But when i add background music the fps get so variable between 49-59. Is there any reason for this? I tried using mp3 and wav but the behavior is the same for both.

Anyway, i know my fps can drop as i add more elements to screen and i don’t pursuit a perfect 60 fps all time. I just want it to be stable because when i add audio and fps get so variable, the movement of the main sprite gets weird: When the fps is low, the sprite moves slow and then when the fps is higher it looks like the sprite is pulled to recover the distance lost in the slow moments. Limiting fps with setAnimationInterval is not working for me, the game always reach 59 fps. I’m afraid when i add more stuff, fps could behave strange and movement of sprites too.

I made some videos for you to appreciate my problem, but i think it is not possible because of the quality. I can show you them if you want.

I tested on a Motorola Atrix 2 with Android 4.0.4 and a WOO tablet with Android 4.0.0. I will test on an ipod 2nd generation in the next few days. My version of cocos2d-x is 2.1.0

Thank you so much for your help.


Background music is played in a new thread. So may be it takes some CPU time.
I have not idea.


well… to me is not a big problem if the audio makes the fps drop, what i dont like is the effect of variable fps on sprite movements. Do you know some way to avoid that…. or a way to set a lower value to fps. CCDirector->SetAnimationInterval is not working to me on android.

Thank you so much.