Cocos2d-x - Spine FPS drop

edited in Questions and Answers
Hi if anyone is using Cocos2d-x, I seriously need help.

When we started our prototype "Who must fall" we were using frame by frame animations and later chose to switch to skeletal animation. You can see below that the framerate before optimization is drawing around 40fps


and immediately after I replace the sprites with skeletal objects, I get a drop in framerate by half which makes the game almost impossible to play.


In the case of above screenshot, I only loaded one spine object, but it seems like it will load every time before it spawns. So is there a way to batch the object so that it only load once? or perhaps is there another way to spawn or delete the objects once its no longer useful. I cant find any useful example online. So can anyone please provide an example.

some anim we made...
800 x 480 - 604K
800 x 480 - 571K
800 x 480 - 604K
800 x 480 - 663K
800 x 480 - 619K
800 x 480 - 614K
736 x 383 - 272K
736 x 378 - 2M
638 x 423 - 5M
563 x 276 - 9M
612 x 278 - 9M
Thanked by 1Bensonance


  • edited
    I don't have cocos-2d experience, but I've worked on several iOS/Android titles, in case more generalised solutions can help. Skeletal meshes are typically quite difficult to batch. If you do it manually, you end up having to reconstruct your new mesh, along with its new world and uv vert positions as well as bone indices and weights (which are a bit tricky because order matters), and doing this regularly to my knowledge would cause you to bleed VBOs (though you don't seem to have particularly high vert counts).

    If you know how many you might need, you might be able to create the batch mesh on the first frame (or even pre-create this), and move the ones you don't need off-screen when they are not in use. (There may be a limit too, dependent on the number of bones per mesh.)

    That said, even on older hardware (iPad 1 type hardware from 5+ years ago), it should be trivial to handle <2k verts and 20 draw calls. Are you sure you're gpu-bound? Can you somehow profile your main thread vs your gpu thread?

    It's possible your skeletal mesh is somehow very inefficient. The more bone weights per vert, the more expensive the mesh. The more bones per mesh, the more expensive. Unity has a 4 weight maximum per vert, and had a 64 bone maximum per mesh, in case those ballpark figures are useful.

    What hardware are you running this on?
  • @SkinnyBoy I can't really help much with your technical problems, just wanted to say the game looks cool! Hope you get a playable build out some time for us to try :)
    Thanked by 1joshken
  • I'm also unable to help with your coding challanges, but wanna agree with @Bensonance that this looks cool! That collage art style is awesome!
Sign In or Register to comment.