Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Feature requests and bug reports
request to integrate this deltatime code into coppercube.

bracer
Registered User
Quote
2019-09-20 02:42:57

When dealing with games, delta time is important as it make sure the speed is the same for different refresh rate.

I wish Coppercube have a built in variable call: system.deltatime.
ccbGetCopperCubeVariable("system.deltatime"); //This will be a read only function, CANNOT and SHOULD NOT be set.


This is the code:
var Delta_Time_Last_Update = Date.now();
var Delta_Time_Now = 0;
var Delta_Time = 0;

var delta_time_enterframe_handle = requestAnimationFrame(delta_time_enterframe);
function delta_time_enterframe(event)
{
Delta_Time_Now = Date.now();
Delta_Time = (Delta_Time_Now - Delta_Time_Last_Update) / (1000/60);
Delta_Time_Last_Update = Delta_Time_Now;

//Or you can access this variable anytime you like, don't have to be inside this function.
console.log(Delta_Time);


delta_time_enterframe_handle = requestAnimationFrame(delta_time_enterframe);
//cancelAnimationFrame(delta_time_enterframe_handle);
}


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "I?ternational" (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