I am developing a game like flappy dunk in CocosCreator using Javascript for Facebook Instant Game.
Game Concept : it is a endless game . there is donut as main character and when click of screen donut jump and move forward towards right side. In path donut have to pass from all the rings in path.
I have created a Ring Node as prefab because i have created a prefab for that. this prefab includes 1 main node and 5 child nodes this all node have RigidBody component and Collider component.
As per my game i am adding a ring prefab dynamically and when donut pass from ring node i remove them from parent node.
First Issue : game is working fine for few mins of game play but after 15-20 mins framerate started dropping and game running very slow.
I searched and got the solution for my First Issue like if i am creating so many prefabs dynamically then i need to use cc.PoolNode to reuse the prefab node from pool. So i have implemented this in my game.
here is my code
Creating new cc.PoolNode
this.ringsNodePool = new cc.NodePool('MovingHole');
Adding Prefab to PoolNode
this.ringsNodePool.put(this.ringPrefabNode);
And getting it again from pool if there is any node available in pool
if (this.ringsNodePool.size()>0){
hole = this.ringsNodePool.get();
}
Second Issue : when i try to get the prefab from pool it remove all the rigid body/ body data from the child nodes of prefabs.
So please help in this situation of any one can solve it.
I am using CocosCreator V1.9 + Javascript.