WINCE下小游戏习作(Q11战斗机)
2006-07-23 11:32:39 来源:WEB开发网核心提示: 2、游戏设置部分这部分的实现比较幼稚,EDIT获得焦点后,WINCE下小游戏习作(Q11战斗机)(2),在相应的hDC区域画出Press Any Key的提示信息,然后无限等待消息(键盘按下)
2、游戏设置部分
这部分的实现比较幼稚,EDIT获得焦点后,在相应的hDC区域画出Press Any Key的提示信息,然后无限等待消息(键盘按下),不知道有没有更好的办法?详情请见“设置窗口回调函数”代码段:
if(HIWORD(wParam) == EN_SETFOCUS)
{
GetCursorPos(&p);
ScreenToClient(hWndSet,&p);
GetClientRect(hWndSet,&rcDlg);
rc.left = p.x;
rc.right = rc.left + 80;
if(rc.right>rcDlg.right)
{
rc.right = rcDlg.right;
rc.left = rc.right - 80;
}
rc.top = p.y;
rc.bottom = rc.top + 20;
hDC = GetDC(hWndSet);
SetBkMode(hDC, TRANSPARENT);
SetTextColor(hDC, RGB(255,0,0));
DrawText(hDC,TEXT("按任意键"),-1,&rc,DT_LEFT);
do
{
//等待键盘按下消息
MSG msg;
GetMessage(&msg,NULL,0,0);
if(msg.message == WM_KEYDOWN)
{
if((vKey = LOWORD(msg.wParam)) != -1)
bPress = TRUE;
}
}while(bPress == FALSE);
swprintf(str,TEXT("%d"),vKey);
//只检测这些特殊键值,其他特殊的几乎不用
if( 0 == wcscmp(str,TEXT("16")) )
wcscpy(str,TEXT("SHIFT"));
else if( 0 == wcscmp(str,TEXT("17")) )
wcscpy(str,TEXT("CONTROL"));
else if( 0 == wcscmp(str,TEXT("32")) )
wcscpy(str,TEXT("SPACE"));
else if( 0 == wcscmp(str,TEXT("37")) )
wcscpy(str,TEXT("LEFT"));
else if( 0 == wcscmp(str,TEXT("38")) )
wcscpy(str,TEXT("UP"));
else if( 0 == wcscmp(str,TEXT("39")) )
wcscpy(str,TEXT("RTGHT"));
else if( 0 == wcscmp(str,TEXT("40")) )
wcscpy(str,TEXT("DOWN"));
else
swprintf(str,TEXT("%c"),vKey);
SetWindowText(::GetFocus(),str);
//SendMessage(hWndSet,WM_NEXTDLGCTL,0,0);
InvalidateRect(hWndSet,&rc,TRUE);
DeleteDC(hDC);
} //end if(HIWORD(wParam) == EN_SETFOCUS) here
3、BOSS的子弹加载和绘制
更多精彩
赞助商链接