Ambiera ForumDiscussions, Help and Support. |
|
|
|||||
|
Hello there. When i run my game it starts at 65 fps, but after a couple of seconds the fps starts going down (as far as under 20 fps). Is there any way i can check what's causing the slowdown? Could it be a instance problem? I have 10 + of the same objects in my scene, but they are all the same duplicated objects/instances so there should be no problem there. |
||||
|
Are you using a terrain? What is your draw distance? Maybe adjusted the ZFar value of the camera, in the property window? |
||||
|
Looks like it was a Javascript problem. I first deleted almost everything from my scene (only player and camera left) but still my fps counter was going down. But when i removed a script then it was stable. Here is the script: (It draws a texture at the mouse position every 1ms) var mouseX = ccbGetMousePosX(); var mouseY = ccbGetMousePosY(); function onFrameDrawing() { var texture = ccbGetCopperCubeVariable("Texture"); var texture2 = ccbGetCopperCubeVariable("Texture2"); if (texture == "glove") { ccbDrawTextureRectangleWithAlpha("glove.png", mouseX-50, mouseY-50, mouseX+50, mouseY+50); } if (texture2 == "glove2") { ccbDrawTextureRectangleWithAlpha("glove2.png", mouseX-50, mouseY-50, mouseX+50, mouseY+50); } } ccbRegisterOnFrameEvent(onFrameDrawing); Is this too much for the Coppercube engine too handle? Is there any other way i can achieve this? |
||||
|
Your game is slowing down because you are registering a new frame event every millisecond, which means after a few seconds there are hundreds of frame events that need to be handled by the engine. Instead of putting your code in "every few seconds do something" put it in "before first drawing do something" |
||||
|
Thanks a lot for the help "smnmhmdy" Putting the code in "before first drawing do something" solved the problem |
|