⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ticktimer.cpp

📁 RGA: Biowaste Game Example This C++ application demonstrates how to create a 2D mobile game for S60
💻 CPP
字号:
#include "TickTimer.h"

CTickTimer::CTickTimer()
	{
	// get the Symbian Tick Counter rate
	// rate is: Ticks * rate = microseconds
	TTimeIntervalMicroSeconds32 rate = 0;
	UserHal::TickPeriod(rate);
	iRateInverse = (TReal64)rate.Int() / 1000000.0;
	iTickFrequency = rate.Int();
	if (iTickFrequency == 0)
		{
		iTickFrequency = 1;
		}
	
	iElapsedSeconds = 0.0;
	iStartTicks = 0;
	iEndTicks = 0;
	}

CTickTimer::~CTickTimer()
	{

	}

void CTickTimer::BeginTimer()
	{
	iStartTicks = User::TickCount();
	}


void CTickTimer::EndTimer()
	{
	iEndTicks = User::TickCount();

	if (iEndTicks == iStartTicks)
		{
		iElapsedSeconds = 0.001f;
		}
	else
		{
		TReal ticks = (TReal64)(iEndTicks - iStartTicks);
		iElapsedSeconds = (TReal64)(ticks * iRateInverse);
		
		// sanity check, if application running worst than 10fps
		// force frametime to 0.1
		if (iElapsedSeconds > 0.1)
			{
			iElapsedSeconds = 0.1;
			}
		}
	}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -