CbuttonPicture.cpp
上传用户:jalin138
上传日期:2022-02-12
资源大小:5720k
文件大小:1k
- #include "CbuttonPicture.h"
- CbuttonPicture::CbuttonPicture(hgeSprite *_spr,
- float _tex,
- float _tey,
- float _tew,
- float _teh,
- float _size )
- {
- m_pSpr = _spr;
- m_texRect.x1 = _tex;
- m_texRect.y1 = _tey;
- m_texRect.x2 = _tew / 2.0f;
- m_texRect.y2 = _teh;
- m_fsize = _size;
- m_bIn = false;
- }
- CbuttonPicture::~CbuttonPicture(void)
- {
- m_pSpr = NULL;
- }
- bool CbuttonPicture::Logic(float _x, float _y)
- {
- m_fX = _x;
- m_fY = _y;
- m_Rect.x1 = _x;
- m_Rect.y1 = _y;
- m_Rect.x2 = _x + m_texRect.x2*m_fsize;
- m_Rect.y2 = _y + m_texRect.y2*m_fsize;
- if ( g_Hge->Input_IsMouseOver() )
- {
- float mt_mouseX = 0.0f, mt_mouseY = 0.0f;
- g_Hge->Input_GetMousePos( &mt_mouseX, &mt_mouseY );
- if ( m_Rect.TestPoint(mt_mouseX, mt_mouseY) )
- {
- m_bIn = true;
- if ( g_Hge->Input_KeyUp(HGEK_LBUTTON) )
- return true;
- return false;
- }
- m_bIn = false;
- }
- return false;
- }
- void CbuttonPicture::Render(void)
- {
- float mt_texX = 0.0f;
- m_bIn == false ? mt_texX = 0.0f : mt_texX = m_texRect.x2;
- m_pSpr->SetTextureRect( m_texRect.x1+mt_texX,
- m_texRect.y1,
- m_texRect.x2,
- m_texRect.y2 );
- m_pSpr->RenderEx( m_fX,
- m_fY,
- 0.0f,
- m_fsize,
- m_fsize );
- }