Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Help with CopperCube
FPS slows down when game is running

poliginal
Registered User
Quote
2021-04-09 01:11:40

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.


nrasool
Registered User
Quote
2021-04-09 14:48:09

Are you using a terrain? What is your draw distance? Maybe adjusted the ZFar value of the camera, in the property window?


poliginal
Registered User
Quote
2021-04-09 15:49:31

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?


smnmhmdy
Registered User
Quote
2021-04-09 16:11:53

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"


poliginal
Registered User
Quote
2021-04-09 16:46:11

Thanks a lot for the help "smnmhmdy"

Putting the code in "before first drawing do something" solved the problem


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Internat?onal" (you are not logged in)


Text:

 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


   






Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact