示例#1
0
    void ScreenMaster::onEvent(const Event::ptr& event){
	switch(event->getEventType()){
	case GAME_START:
	    gameScreen();
	    break;
	}
    }
示例#2
0
    void StartScreen::onEvent(const Event::ptr& event){
	HSG_DEBUG("StartScreen::onEvent");
	switch(event->getEventType()){
	case SYSTEM_MOUSE_CLICK:
	{
	    EventClick* clickEvent = (EventClick*)event.get();

	    Vector3 gameCoords = m_coordSystem->toGameCoords(clickEvent->x, clickEvent->y);
	    float left = m_buttonSprite->getLocation().x - m_buttonSprite->getWidth() / 2;
	    float right = m_buttonSprite->getLocation().x  + m_buttonSprite->getWidth() / 2;
	    float top = m_buttonSprite->getLocation().y  + m_buttonSprite->getHeight() / 2;
	    float bottom = m_buttonSprite->getLocation().y  - m_buttonSprite->getHeight() / 2;

	    if(gameCoords.x > left && gameCoords.x < right
	       && gameCoords.y < top && gameCoords.y > bottom){

		m_gameQueue->postEvent(Event::ptr(new Event(GAME_START)));
	    }
	}
	break;
	}
    }