Jump to content

Timer in Leadwerks 3.3


Pyditn
 Share

Recommended Posts

You will need Time::GetCurrent() for this. This returns the time the application has been running for in milliseconds.

 

You basically keep a variable with the time of when it's started, and constantly check if the Current time minus the start time (so the elapsed time) is bigger or equal than the requirement.

 

Code would look like this:

float fStartTime = 0;
float fRequiredTime = 5000; // in milliseconds
bool bStartChecking = false;
void OnCollision(){
fStartTime = (float)Leadwerks::Time::GetCurrent(); // Have to convert from long long to float
bStartChecking = true;
}
void Update(){
if (bStartChecking){
 if ((float)Leadwerks::Time::GetCurrent() - fStartTime >= fRequiredTime){
	 // Do stuff when time has ended
 }
}
}

Using Leadwerks Professional Edition (Beta), mainly using C++.

Windows 10 / Linux Mint, Visual Studio 2017. GPU: NVidia GeForce GTX970, CPU: Intel i7 7700K @ 4.20 GHz

Previously known as Evayr.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...