StateMenu.cpp
上传用户:jalin138
上传日期:2022-02-12
资源大小:5720k
文件大小:1k
- #include "StateMenu.h"
- #include "StatePlay.h"
- #include "StateInfo.h"
- #include <stdio.h>
- CStateMenu::CStateMenu(void)
- {
- memset(m_pButton, NULL, sizeof(m_pButton));
-
- char sprName[64] = {0};
- hgeSprite *mt_spr = NULL;
- for (int i = 0;i < 4;i ++)
- {
- sprintf_s(sprName, sizeof(sprName), "Button%d",i+1);
- mt_spr = g_Res->GetSprite( sprName );
- m_pButton[i] = new CbuttonPicture( mt_spr,
- 246.0f,
- 371.0f + i * 20.0f,
- 160.0f,
- 20.0f,
- 1.5f );
- }
- mt_spr = NULL;
- m_nState = 0;
- }
- CStateMenu::~CStateMenu(void)
- {
- for (int i = 0;i < 4;i ++)
- {
- SAFE_DELETE( m_pButton[i] );
- }
- }
- // 实现逻辑接口
- bool CStateMenu::Logic(void)
- {
-
- for (int i = 0;i < 4;i ++)
- {
- if ( m_pButton[i]->Logic( 27.0f,270.0f+i*40.0f ) )
- {
- m_nState = i;
- return true;
- }
- }
- return false;
- }
- // 实现渲染接口
- void CStateMenu::Render(void)
- {
- RenderBack();
- for (int i = 0;i < 4;i ++)
- {
- m_pButton[i]->Render();
- }
- }
- // 实现改变状态接口
- bool CStateMenu::Handle(CSceneManage *_SceneManage)
- {
- if ( NULL == _SceneManage )
- return false;
- switch ( m_nState )
- {
- case 0:
- _SceneManage->ChangeState( new CStatePlay() );
- break;
- case 1:
- break;
- case 2:
- _SceneManage->ChangeState( new CStateInfo() );
- break;
- case 3:
- return true;
- break;
- default:
- break;
- }
- return false;
- }