本文整理汇总了C#中Timer.read方法的典型用法代码示例。如果您正苦于以下问题:C# Timer.read方法的具体用法?C# Timer.read怎么用?C# Timer.read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Timer
的用法示例。
在下文中一共展示了Timer.read方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Run
public void Run(Control root)
{
SDCardManager.Mount();
// load in the system font
_systemFont = Font.LoadFromFile("DEJAVU.FNT");
var timer = new Timer();
timer.start();
// for fps info update
float lastDebugTime = 0;
float lastUpdateTime = 0;
string infoString = "";
while (true)
{
FrameTime = timer.read();
// fixed time step - both for update and draw
if (FrameTime - lastUpdateTime >= DeltaTime)
{
int touches = Touch.GetTouchInfo();
for (int i = 0; i < touches; i++)
{
// near a touch we have seen recently ?
var previous = _activeTouches.Find(x => Math.Abs(x.Position.X - Touch.X[i]) < TouchTrackTolerance &&
Math.Abs(x.Position.Y - Touch.Y[i]) < TouchTrackTolerance);
if (previous == null)
{
_nextTouchId++;
// remember this touch
_activeTouches.Add(new TouchInfo { Position = new Point((int)Touch.X[i], (int)Touch.Y[i]), LastSeenTime = FrameTime, Id = _nextTouchId });
// new touch so send message to root control
root.SendMessage(UIMessage.TouchStart, new TouchEventArgs(_nextTouchId, new Point((int)Touch.X[i], (int)Touch.Y[i])));
}
else
{
bool hasMoved = (Math.Abs(previous.Position.X - Touch.X[i]) > 0 || Math.Abs(previous.Position.Y - Touch.Y[i]) > 0);
// touch seen again - update for tracking
previous.Position = new Point((int)Touch.X[i], (int)Touch.Y[i]);
previous.LastSeenTime = FrameTime;
// moved at all ?
if (hasMoved)
{
root.SendMessage(UIMessage.TouchMove, new TouchEventArgs(previous.Id, previous.Position));
}
}
}
// get rid of old touches
for (int i = _activeTouches.Count - 1; i >= 0; i--)
{
if (FrameTime - _activeTouches[i].LastSeenTime > 0.1f)
{
root.SendMessage(UIMessage.TouchEnd, new TouchEventArgs(_activeTouches[i].Id, _activeTouches[i].Position));
_activeTouches.RemoveAt(i);
}
}
lastUpdateTime = FrameTime;
Display.Clear(0xFFFFFFFF);
root.Update(DeltaTime);
root.Draw();
if (ShowDebug)
{
// show debug info every couple of seconds
if (timer.read_ms() - lastDebugTime > 2.0f)
{
// string.format broken?
//infoString = String.Format("FPS: {0} MEMAVAIL: {1} MEMALOC: {2}",
// Display.Fps,
// Microsoft.Zelig.Runtime.MemoryManager.Instance.AvailableMemory,
// Microsoft.Zelig.Runtime.MemoryManager.Instance.AllocatedMemory);
infoString = "FPS: " + Display.Fps.ToString() + " MEMAVAIL: " + Microsoft.Zelig.Runtime.MemoryManager.Instance.AvailableMemory.ToString();
lastDebugTime = timer.read();
}
//Display.DrawString(infoString, 0, 0);
}
// show the back buffer
Display.Flip();
}
}
}