直接写屏和特殊系统事件
来源:互联网 发布:多目标优化是什么 编辑:程序博客网 时间:2024/05/30 22:43
我们先说AbortNow,它的处理比较简单。你之需在其中停止驱动游戏逻辑的计时器(一般是个CPeriodic对象),停止声音模块(一般是一个CActive任务)就可以了。
值得费些力气的是Restart函数,它并不是在应用程序回到前台,并且可以进行全屏直接写屏时才被回调。所以不能在此时武断的恢复游戏逻辑,开始游戏。
首先,你要调用CDirectScreenAccess::StartL( )恢复直接写屏。但是必须给这个函数加上TRAP保护。因为它很可能抛出KErrNotReady异常。如果遇到这个异常,那你就直接返回好了,因为直接写屏此时并不能开始。接下来你需要检查一下绘图区域,看是否整个屏幕都可以被使用。如果不是,那也无需启动游戏逻辑,只需要用最后保留的后台缓冲区的内容更新直接写屏区域即可。第三种情况,如果直接写屏成功启动,并且整个屏幕都可以被绘制,才启动游戏逻辑,启动声音等其它模块。
完整的代码如下:
void CEngine::AbortNow(RDirectScreenAccess::TTerminationReasons /*aReason*/)
{
// Cancel timer and display
if (iGameTimer->IsActive())
iGameTimer->CancelTimer();
if (!iGameWorldPaused)
{
iGameWorldPaused = ETrue;
iGameWorld->PauseGame(); // Pause audio stream etc.
}
iPaused = ETrue;
}
void CEngine::Restart(RDirectScreenAccess::TTerminationReasons /*aReason*/)
{
TRAPD(error, SetupDirectScreenAccessL());
switch(error)
{
case KErrNone:
break;
case KErrNotReady:
if (iDirectScreenAccess->IsActive())
iDirectScreenAccess->Cancel();
if (iGameTimer->IsActive())
iGameTimer->CancelTimer();
if (!iGameWorldPaused)
{
iGameWorldPaused = ETrue;
iGameWorld->PauseGame();
}
return;
default:
User::Panic(_L("Setup DSA Error"), error);
}
if(iPaused)
{
if(iGameDawingArea == iRegion->BoundingRect())
{
iPaused = EFalse;
if(!iGameTimer->IsActive())
{
iGameWorldPaused = EFalse;
iGameWorld->ResumeGame();
iGameTimer->Restart();
}
}
else
{
PauseFrame();
}
}
else
{
if(!iGameTimer->IsActive())
{
iGameTimer->Restart();
}
}
}
void CEngine::SetupDirectScreenAccessL()
{
// Initialise DSA
iDirectScreenAccess->StartL();
// Get graphics context for it
iGc = iDirectScreenAccess->Gc();
// Get region that DSA can draw in
iRegion = iDirectScreenAccess->DrawingRegion();
// Set the display to clip to this region
iGc->SetClippingRegion(iRegion);
}
void CEngine::PauseFrame()
{
// Force screen update: this is required for WINS, but may
// not be for all hardware:
iDirectScreenAccess->ScreenDevice()->Update();
// and draw from unchanged offscreen bitmap
iGc->BitBlt(TPoint(0,0), &(iDoubleBufferedArea->GetDoubleBufferedAreaBitmap()));
iClient.Flush();
}
};
- 直接写屏和特殊系统事件
- 直接写屏和特殊系统事件
- DSA(直接写屏)和双缓冲
- 关于直接写屏
- DOS直接写屏
- 关于直接写屏
- 直接写屏
- 直接通过framebuffer直接写屏
- Input的特殊事件onpopertychange和oninput
- Input的特殊事件onpopertychange和oninput
- 直接写屏显示文字
- 使用汇编直接写屏
- RGB24数据直接写屏
- WINCE实现直接写屏
- WINCE实现直接写屏
- NGUI事件系统、相关变量、控件等的直接用法
- NGUI事件系统、相关变量、控件等的直接用法
- NGUI事件系统、相关变量、控件等的直接用法
- 郭台铭——白手起家
- Windows2003上VS2005 SP1 安装失败的解决方案
- 安全的图像引擎
- (WPF学习记录)第八章 Dependency Property
- delphi组件开发
- 直接写屏和特殊系统事件
- 常用的js动态增加(删除)table数据行的功能
- pl/sql update 关联表的问题
- SqlDataAdapter可以用SqlCommandBuilder 实现批量更新
- How to fit text in rectangle-MSDN
- SQL操作全集
- 达芬奇技术简介
- 关于用javascript改变class所用的setAttribute()方法
- 单片机破解的常用方法及应对策略