Hi. Im making a game using cocos2dx 3.17.2 (on android)
The game is not running smoothly, fps is low. Especially on some devices.
There is too much code inside schedule( … ) functions but i doubt its the reason of low fps.Im running game in debug mode and all sprites have separate texture files, if it matters. Please help me to find a solution
Profile your code… see which functions and sub functions are consuming the most time… generally this either falls on the side of the GPU not being able to draw an inefficient set of instructions fast enough, or on the CPU side trying to compute too much (inefficiently/sequentially) inside the update time step…
If you have an nVidia GPU and use Windows, then build a Win32 version of your application, and use nsight-graphics to profile it. You can see what is being sent to the GPU every single draw call (among other useful bits of information).
62 draw calls is not so much to cause slowdowns. If you can open your project in xcode, run it o iphone, then you can get full graphics profile. Anyway, just try to put your sprites in one-two big textures and see if slowdowns are gone…
If Android Studio isn’t enough to help you track down your issues, and you are using Windows, then try Visual Studio 2019. Create a Visual Studio solution for your application using cmake, then open up the solution in Visual Studio, then use the profiling functionality in it (menu ANALYZE->Performance Profiler).
I tried a lot of things (sprite sheet, disabling sounds…) but nothing worked. Fps is around 58-60 but its lagging, not running seamlessly. I couldnt find the problem with profiling tool either
You might want to analyze the same code on Windows as many people are suggesting. Most importantly, DON’T profile performance with debug builds!
Also, when you see the game “lagging”, are there actions that are being triggered irregularly. I’d consider hacking away at code and functionality to remove as much as possible to get the FPS that you desire, then adding things back slowly to see what introduces the lag.