// Button.cpp: implementation of the CButton class. // ////////////////////////////////////////////////////////////////////// #include "Button.h" ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// void CButton::SetImage(UINT uiImage){ HINSTANCE hInstance=GameEngine::GetEngine()->GetInstance(); HWND hwnd=GameEngine::GetEngine()->GetWindow(); HDC hDC=GetDC(hwnd); for(int i=0;i<3;i++){ bmpButton[i]=new Bitmap(hDC,uiImage+i,hInstance); } iwidth=bmpButton[0]->GetWidth(); iheight=bmpButton[0]->GetHeight(); ReleaseDC(hwnd,hDC); iCurrentImage=0; bHold=false; isReady=false; bOnceMoved=false; } void CButton::SetPlace(int ix,int iy,bool bReady){ CButton::ix=ix; CButton::iy=iy; isReady=bReady; } CButton::~CButton() { } bool CButton::MouseButtonDown(int x,int y,BOOL bLeft){ if(!(x>ix && xiy && yix && xiy && yIsSoundOn()) PlaySound((LPCSTR)IDW_IN, GameEngine::GetEngine()->GetInstance(), SND_ASYNC | SND_RESOURCE); return true; } return false; } bool CButton::MouseMove(int x,int y){ if(!(x>ix && xiy && yIsSoundOn()) PlaySound((LPCSTR)IDW_OVER, GameEngine::GetEngine()->GetInstance(), SND_ASYNC | SND_RESOURCE); bOnceMoved=true; return true; } void CButton::DrawScreen(HDC hDC){ if(isReady) bmpButton[iCurrentImage]->Draw(hDC,ix,iy,true); }