⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hgeguibuttonex.cpp

📁 我在资源网上发布的一个brickshorterjr的代码
💻 CPP
字号:
/***********************************************************************************************
**	File: hgeGUIButtonEx.cpp
**  Author:Kevin Lynx
**  Date: 2006.10.1
**  Desc: Create a GUI button, it's different from hgeGUIButton,because its state
**        is changed by the MouseMove but not mouse clicked!
**        It's still a two status button!
************************************************************************************************/
#include	"hgeGUIButtonEx.h"

hgeGUIButtonEx::hgeGUIButtonEx( int _id, float x, float y, float w, float h,
							    hgeSprite *mouseOn, hgeSprite *mouseOff )
{
	id			=	_id;
	bStatic		=	false;
	bVisible	=	true;
	bEnabled	=	true;
	rect.Set(x, y, x+w, y+h);

	m_bPressed	=	false;
	m_bMouseOn	=	false;

	m_sprMouseOn	=	mouseOn;
	m_sprMouseOff	=	mouseOff;

	m_sprDisable	=	NULL;
}

hgeGUIButtonEx::~hgeGUIButtonEx()
{
	//do nothing,because the sprites are created by outside world
}

void	hgeGUIButtonEx::Render()
{
	if( m_bMouseOn )
	{
		m_sprMouseOn->Render( rect.x1, rect.y1 );
	}
	else
	{
		m_sprMouseOff->Render( rect.x1, rect.y1 );
	}

	if( !bEnabled &&
		m_sprDisable != NULL )
	{
		m_sprDisable->Render( rect.x1, rect.y1 );
	}
}

bool hgeGUIButtonEx::MouseLButton(bool bDown)
{
	if(bDown)
	{
		m_bPressed=true;
		return false;
	}
	else
	{
		m_bPressed=false;
		return true; 
	}
}

void	hgeGUIButtonEx::MouseOver( bool bOver )
{
	m_bMouseOn	=	bOver;
}

void	hgeGUIButtonEx::Enable( bool bEnable, hgeSprite *disableSp )
{
	bEnabled	=	bEnable;

	if( disableSp != NULL )
	{
		m_sprDisable = disableSp;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -