Continuos FPS drop and never recovers.

Continuos FPS drop and never recovers.
0.0 0


I am creating a game using cocos2dx 2.1.4. Its FPS drops continuously , and never recover.

Background about the way I am doing things:-
Its game about scrolling down some shapes, each shape is made up of some square blocks.I have 7 kind of blocks. All loaded in a Sprite Sheet and using these blocks from this sprite sheet I create a shape.
A level file is consist of these shapes. I load two levels at the same time one onscreen and another off screen to make it seamless scrolling. For loading two levels at the same time I used two different CCSprite game batch nodes as :-

*gameBatchNode1 = CCSpriteBatchNode::create;
*gameBatchNode2= CCSpriteBatchNode::create;
The problem I am facing is that as I keep on playing the game frame rate drops continuously , from 60 fps till 10 fps and never recovers or might recover in near future , as I observed for 20 minutes but its too much time to wait.
My observations:~~

1> I used Time profiler it shows maximum time is in draw() calls. Also if I play game very fast the peak of time increases in track, that should be fine as I am giving more work to do, but once a peak is attained it remains approximately at that height only, even if I leave the game Idle. Is it normal ? According to me it should have returned to its normal peak once the current work is done.

2> Some where I thought its happening because I used two batch nodes and removing its children on a user touch immediately might causing it slow but then after removing the children it should run normal. to give an idea is it ok to remove 10 children from batch node immediately ? some guys say its very slow process. Just to check if this causing problem , I did :-
Instead of removing them I just set visibility of the children to false.But still FPS drops and never recovers.

Please share your thoughts on this.


What does your draw call count say? Is it rising constantly?


How to check draw counts ?


It should be on the bottom left corner. There are three rows of numbers. The number on the top is the draw call count.


Oh thanks! for the pointer, and yes its increasing constantly. Is it not supposed to increase this way ?


This means that the old SpriteBatches are not deleted. This is why your game gets slower the longer the game runs.


Thanks Martin, Just found that with every touch, I am adding 8 new sprites to the layer, and its adding every time I touch . So with time I am giving more and more work to do. This must be the problem.

Actually I wanted to replace the sprite at 8 places with a touch, the way I was doing every time :-

but it should have been :-

Seems like it is the problem