I am using Cocos2dx 3.2 and box2d.I want to develope the game which is similar to "Tumbler" example which is given in test projects.
I am using this example code as base code of my game but facing a problem as dynamic body is increasing performance of game is getting down. Given example code is also contain same issue.
I’ve got a enough dynamic bodies to build a castle in my app and it doesn’t make a tiny difference to the performance or frame rate. Solid 60fps. You’re either running the app in the simulator or doing something drastically wrong elsewhere. Also you haven’t posted any code or given any examples from the debugger etc. I can assure you there’s no performance issues with box2D it’s one of the most optimized sdk’s out there.
Hmm that’s quite a lot of box shapes. Well for reference, I would disregard the simulator if you have a device. The simulator is slow and very innefficient. It’s only really useful for testing graphics on different size devices if you don’t have one of each.
The main fps drain for box2d is without a doubt DebugDraw. It’s super expensive, you have to save and restore GL state. So you will notice that if you turn off debug draw and draw sprites at all the positions and rotations of the bodies. You will get a huge leap in FPS performance. Debug draw certainly has it’s uses but obviously you won’t have debug draw turned on in your release version. So use the fps without debug draw to get an idea of release quality fps.
If i turned off debug draw only 15% performance increases but the performance issue is still there.
Turned off debug draw is not perfect solution for this.
Turned On debug draw ==> performance down after 150 dynamic body
Turned off debug draw ==> performance down after 165 dynamic body.
I’d start from scratch then rather than using the example. Write your own code and see if you get the same problem. I’ve never had performance issues with that many bodies.