-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCShotPowerIndicator.cpp
More file actions
36 lines (28 loc) · 1.01 KB
/
CShotPowerIndicator.cpp
File metadata and controls
36 lines (28 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include "CShotPowerIndicator.h"
BOOL CShotPowerIndicator::Create(CDXUTDialog* pDialog, int nID, int nResourceIndex, RECT* prcIndicateRange, RECT* prcCntRange, RECT* prcTexture)
{
if (!pDialog || !prcIndicateRange || !prcCntRange || !prcTexture)
return FALSE;
CDXUTSprite* pSprite = NULL;
if (FAILED(pDialog->AddSprite(nID, prcCntRange->left, prcCntRange->top, prcCntRange->right, prcCntRange->bottom, false, &pSprite)))
return FALSE;
pSprite->GetElement(0)->SetTexture(nResourceIndex, prcTexture);
CopyRect(&m_rcIndicateRange, prcIndicateRange);
CopyRect(&m_rcControl, prcCntRange);
p_pDialog = pDialog;
m_nID = nID;
m_pSprite = pSprite;
m_bCreated = TRUE;
return TRUE;
}
void CShotPowerIndicator::OnMouseClick(int nX, int nY)
{
if (!m_bCreated) return;
if (m_rcIndicateRange.left <= nX && nX <= m_rcIndicateRange.right
&& m_rcIndicateRange.top <= nY && nY <= m_rcIndicateRange.bottom)
{
int nCX = nX - ((m_rcControl.right) / 2);
m_nCX = nX-127;
m_pSprite->SetLocation(nCX, m_pSprite->m_y);
}
}