当前位置: 首页>>代码示例>>C++>>正文


C++ CInput::GetMousePosX方法代码示例

本文整理汇总了C++中CInput::GetMousePosX方法的典型用法代码示例。如果您正苦于以下问题:C++ CInput::GetMousePosX方法的具体用法?C++ CInput::GetMousePosX怎么用?C++ CInput::GetMousePosX使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CInput的用法示例。


在下文中一共展示了CInput::GetMousePosX方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Input

bool CPauseState::Input( CInput& _input )
{
	static bool ifPressedD = false;
	static bool ifPressedU = false;
	static bool ifPressedEnter_Paused = false;

	// Updates the reticle location based on the mouse pos.
	m_reticle.SetPosX(_input.GetMousePosX() - m_reticle.GetRect().GetWidth() * 0.5f);
	m_reticle.SetPosY(_input.GetMousePosY() - m_reticle.GetRect().GetHeight() * 0.5f);
	m_reticle.BuildGeometry(m_Renderer->GetScreenWidth(), m_Renderer->GetScreenHeight());


	//Mouse Active over keybard
	if(_input.GetMousePosX() == m_PrevMousePosX && _input.GetMousePosY() == m_PrevMousePosY)
	{
		m_bMouseActive = false;
	}
	if(_input.GetMousePosX() != m_PrevMousePosX)
	{
		m_bMouseActive = true;
		m_PrevMousePosX = _input.GetMousePosX();
	}
	if(_input.GetMousePosY() != m_PrevMousePosY)
	{
		m_bMouseActive = true;
		m_PrevMousePosY = _input.GetMousePosY();
	}

	if (m_Timer > 0.5f)
	{
		static bool ifPressEsc = true;
		if(_input.IsEscapePressed() )
		{
			if(!ifPressEsc)
			{
				m_bFadeOut = true;
				m_Esc = true;
				m_Choice = P_PLAY;
				ifPressEsc = true;
///				AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_FX_2D_MENUUNPAUSE);
			}
		}
		else
			ifPressEsc = false;
	}

	if (m_bFadeOut && m_FadeTimer >= 1.0f )
	{
		switch(m_Choice)
		{
		case P_PLAY:
			{
//				AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_FX_2D_MENUUNPAUSE);
				m_Game->GetStateManager()->PopState();
				return true;
			}
			break;
		case P_OPTIONS:
			{
//				AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_FX_2D_MENUACCEPT);
				AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_SFX_MENU_ACCEPT);

				m_Game->GetStateManager()->PushState(OPTIONS_STATE);
				return true;
			}
			break;
		case P_EXIT:
			{
//				AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_FX_2D_MENUACCEPT);
				AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_SFX_MENU_ACCEPT);

				m_Game->GetStateManager()->ChangeState(MAINMENU_STATE);
				return true;
			}
			break;
		};

		
	}

	//KEYBOARD INPUT FOR SELECTING BUTTONS----------------------------------------------------------------------	
#pragma region Keyboard Input for Selecting Buttons


	if((_input.KeyDown(DIK_S) || _input.KeyDown(DIK_DOWN) || _input.GetController().GetControllerState().Gamepad.sThumbLY < - 8000 ||
		_input.GetController().GetControllerState().Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_DOWN)  && !m_bFadeOut )
	{
		if(!ifPressedD)
		{
			m_Choice++;
			//m_PauseElements[PAUSE_HIGHLIGHTED_ELEMENTS].SetPosX((m_Game->GetScreenWidth() / 2.0f) - 150);
			//m_PauseElements[PAUSE_HIGHLIGHTED_ELEMENTS].SetPosY(m_Choice * 128.0f + 128.0f);
			//m_PauseElements[PAUSE_HIGHLIGHTED_ELEMENTS].BuildGeometry();
			if(m_Choice == PAUSE_NUM_CHOICES)
			{
				m_Choice = P_PLAY;
				//m_PauseElements[PAUSE_HIGHLIGHTED_ELEMENTS].SetPosY((m_Game->GetScreenHeight() / 2.0f) - 160);
				//m_PauseElements[PAUSE_HIGHLIGHTED_ELEMENTS].BuildGeometry();
			}
			ifPressedD = true;
//.........这里部分代码省略.........
开发者ID:dtbinh,项目名称:FinalProject2,代码行数:101,代码来源:PauseState.cpp

示例2: Input

bool WinState::Input(CInput& _input )
{
	_input.ReadMouse();
	_input.ReadKeyboard();

	static bool ifPressedD_WIN = false;
	static bool ifPressedU_WIN = false;
	static bool ifPressedEnter_WIN = false;

	// Updates the reticle location based on the mouse pos.
	m_reticle.SetPosX(_input.GetMousePosX() - m_reticle.GetRect().GetWidth() * 0.5f);
	m_reticle.SetPosY(_input.GetMousePosY() - m_reticle.GetRect().GetHeight() * 0.5f);
	m_reticle.BuildGeometry(m_Renderer->GetScreenWidth(), m_Renderer->GetScreenHeight());

	//Mouse Active over keybard
	if(_input.GetMousePosX() == m_PrevMousePosX && _input.GetMousePosY() == m_PrevMousePosY)
	{
		m_bMouseActive = false;
	}
	if(_input.GetMousePosX() != m_PrevMousePosX)
	{
		m_bMouseActive = true;
		m_PrevMousePosX = _input.GetMousePosX();
	}
	if(_input.GetMousePosY() != m_PrevMousePosY)
	{
		m_bMouseActive = true;
		m_PrevMousePosY = _input.GetMousePosY();
	}

	static bool ifPressedEsc_WIN = false;
	if(!ifPressedEsc_WIN)
	{
		ifPressedEsc_WIN = true;
		if(_input.KeyDown(DIK_ESCAPE))
		{
			m_bFadeOut = true;
			if (m_bEsc)
			{
				m_bEsc = false;
			}
			if (m_bSoundCheck)
			{
				//				AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_FX_2D_MENUACCEPT);
				AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_SFX_MENU_ACCEPT);

				m_bSoundCheck = false;
			}
			return true;
		}
	}
	else
		ifPressedEsc_WIN = false;

	//MOUSE INPUT FOR SELECTING BUTTONS----------------------------------------------------------------------	
#pragma region Mouse Input for Selecting Buttons

	int _mouseX =			_input.GetMousePosX();
	int _mouseY =			_input.GetMousePosY();

	//MAIN MENU BUTTON
	//float _mainWidth1 =			m_WinElements[WIN_MAIN_ELEMENT].GetRect().GetWidth();		//256
	//float _mainHeight1 =		m_WinElements[WIN_MAIN_ELEMENT].GetRect().GetHeight();		//64
	//float _mainPosX1 =			m_WinElements[WIN_MAIN_ELEMENT].GetPosX();		//280
	//float _mainPosY1 =			m_WinElements[WIN_MAIN_ELEMENT].GetPosY();		//612
	//float _mainCombinedX1 =		_mainPosX1 + _mainWidth1;						//536
	//float _mainCombinedY1 =		_mainPosY1 + _mainHeight1;						//676

	//if (_mouseX >= _mainPosX1 && _mouseX <= _mainCombinedX1 && _mouseY <= _mainCombinedY1 && _mouseY >= _mainPosY1)
	//{
	//	if (m_FadeTimer <= 1.0f && !m_bFadeOut)	//Fadded in, set to 0, and not FadeOut.
	//	{
	//		if (m_bMouseActive)
	//		{
	//			m_Choice = W_MAIN_MENU;
	//			if (m_bSoundMain)
	//			{
	//				//					AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_FX_2D_MENUMOVE_HOVER);
	//				AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_SFX_MENU_HOVER);

	//				m_bSoundMain = false;
	//				m_bSoundCredits = true;
	//			}
	//		}
	//		if (m_Timer > 0.5f)
	//		{
	//			if (_input.IsLeftClicked())
	//			{
	//				//					AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_FX_2D_MENUACCEPT);
	//				AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_SFX_MENU_ACCEPT);

	//				m_bFadeOut = true;
	//			}
	//			/*ProcessStates((eWinChoices)m_Choice);*/
	//		}
	//	}
	//}

	//CREDITS BUTTON
	float _creditsWidth1 =		m_WinElements[WIN_CREDITS_ELEMENT].GetRect().GetWidth();		//256
//.........这里部分代码省略.........
开发者ID:dtbinh,项目名称:FinalProject2,代码行数:101,代码来源:WinState.cpp

示例3: Input

bool CDifficultyMenu::Input( CInput& _input )
{	
	_input.ReadMouse();
	_input.ReadKeyboard();

	static bool ifPressedDown = false;
	static bool ifPressedUp = false;
	static bool ifPressedEnter1 = false;
	static bool ifPressedEnter2 = false;
	//static bool ifPressedEsc = false;

	// Updates the reticle location based on the mouse pos.
	m_reticle.SetPosX(_input.GetMousePosX() - m_reticle.GetRect().GetWidth() * 0.5f);
	m_reticle.SetPosY(_input.GetMousePosY() - m_reticle.GetRect().GetHeight() * 0.5f);
	m_reticle.BuildGeometry(m_Renderer->GetScreenWidth(), m_Renderer->GetScreenHeight());

	if(_input.GetMousePosX() == m_PrevMousePosX && _input.GetMousePosY() == m_PrevMousePosY)
		m_MouseActive = true;

	if(_input.GetMousePosX() != m_PrevMousePosX || _input.GetMousePosY() != m_PrevMousePosY)
	{
		m_MouseActive = true;
		m_PrevMousePosX = _input.GetMousePosX();
		m_PrevMousePosY = _input.GetMousePosY();
	}

		//Esc (EXIT THE PROGRAM)
	static bool ifPressedEsc_Cred = false;
	if(!ifPressedEsc_Cred)
	{
		if(_input.KeyDown(DIK_ESCAPE))
		{
			m_Choice = CHOICE_BACK;
			m_FadeOut = true;
			ifPressedEsc_Cred = true;
			return true;
		}
	}
	else
		ifPressedEsc_Cred = false;

#pragma region Keyboard inputs
	if(_input.KeyDown(DIK_S) || _input.KeyDown(DIK_DOWN) || _input.GetController().GetControllerState().Gamepad.sThumbLY < - 8000 || _input.GetController().GetControllerState().Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_DOWN )
	{
		if(m_FadeTimer <= 1.0f && !m_FadeOut)
		{
			if(!ifPressedDown)
			{
				m_Choice++;
				if(m_Choice == CHOICE_TOTAL)
				{
					m_Choice = CHOICE_EASY;
				}
				ifPressedDown = true;
			}
		}
	}
	else
		ifPressedDown = false;

	if(_input.KeyDown(DIK_W) || _input.KeyDown(DIK_UP) || _input.GetController().GetControllerState().Gamepad.sThumbLY > 8000 || _input.GetController().GetControllerState().Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_UP)
	{
		if(m_FadeTimer <= 1.0f && !m_FadeOut)
		{
			if(!ifPressedUp)
			{
				m_Choice--;
				if(m_Choice < 0)
				{
					m_Choice = CHOICE_BACK;
				}
				ifPressedUp = true;
			}
		}
	}
	else
		ifPressedUp = false;
#pragma endregion

	switch(m_Choice)
	{
	case CHOICE_EASY:
		{
			if(m_SoundEasy)
			{
//				AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_FX_2D_MENUMOVE_HOVER);
				AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_SFX_MENU_HOVER);

				m_SoundEasy = false;
				m_SoundNormal = true;
				m_SoundHard = true;
				m_SoundBack = true;
				m_isHighlighted = true;
			}
		}
		break;
	case CHOICE_NORMAL:
		{
			if(m_SoundNormal)
			{
//.........这里部分代码省略.........
开发者ID:dtbinh,项目名称:FinalProject2,代码行数:101,代码来源:DifficultyMenu.cpp


注:本文中的CInput::GetMousePosX方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。