コード例 #1
0
bool
SplashSceneLayer::handleEvent(const Event::IEvent &e)
{
	if (e.type() == Event::KeyboardEvent::Type())
		return(skip());
	return(false);
}
コード例 #2
0
	VIRTUAL bool handleEvent(const Event::IEvent &e)
	{
		using namespace Input;

		if (EngineBase::handleEvent(e))
			return(true);

		if (e.type() != Event::KeyboardEvent::Type())
			return(false);

		const Event::KeyboardEvent &l_kevent =
		    static_cast<const Event::KeyboardEvent &>(e);

		if (l_kevent.action() != Keyboard::KeyPressed)
			return(false);

		if (l_kevent.key() == Keyboard::KBK_RETURN ||
                    l_kevent.key() == Keyboard::KBK_Y) {
			Game::SharedScene l_scene = sceneManager()->activeScene();
			if (l_scene->getLayer("pause"))
				l_scene->removeLayer("pause");
			else
				l_scene->pushLayer(new Game::PauseSceneLayer("pause", *l_scene));
		} else if (l_kevent.key() == Keyboard::KBK_ESCAPE ||
                           l_kevent.key() == Keyboard::KBK_P) {
			stop();
		} else return(false);

		return(true);
	}
コード例 #3
0
bool
EngineBase::handleEvent(const Event::IEvent &e)
{
	if (e.type() == Core::Type("Event::QuitEvent")) {
		const Event::QuitEvent *l_qe = static_cast<const Event::QuitEvent *>(&e);
		stop(l_qe ? l_qe->code() : 0);
		return(true);
	}
	return(false);
}
コード例 #4
0
bool
PlayerEntity::handleEvent(const Event::IEvent &e)
{
	if (e.type() == Common::DoomEvent::Type()) {
		m_animation_component->play("dying", true);

		m_collider_component->disable();
		m_input_component->disable();

		m_movement_component->velocity()[0] = 0;
		m_movement_component->velocity()[1] = 500;
		m_movement_component->acceleration()[0] = 0;
		m_movement_component->acceleration()[1] = -1000;

		/*
		 * Reload in 1500 milliseconds
		 */
		Event::EventManager::Instance()->queue(new Common::DeathEvent(NOW() + 2000));

		return(true);
	}

	else if (e.type() == Common::WarpEvent::Type()) {
		m_collider_component->disable();
		m_input_component->disable();

		m_movement_component->velocity()[0] = 0;
		m_movement_component->velocity()[1] = 0;
		m_movement_component->acceleration()[0] = 0;
		m_movement_component->acceleration()[1] = 0;

		const Common::WarpEvent &l_warp_event =
		    static_cast<const Common::WarpEvent &>(e);
		Event::EventManager::Instance()->queue(new Common::WarpEvent(l_warp_event.destination()));
		return(true);
	}

	return(false);
}
コード例 #5
0
bool
InputComponent::handleEvent(const Event::IEvent &e)
{
	using namespace Input;

	if (e.type() != Event::KeyboardEvent::Type())
		return(false);

	const Event::KeyboardEvent &l_kevent =
	    static_cast<const Event::KeyboardEvent &>(e);

	if (l_kevent.key() == Keyboard::KBK_SPACE)
		jump(l_kevent.action() == Keyboard::KeyPressed);
	else if (l_kevent.key() == Keyboard::KBK_LEFT)
		left(l_kevent.action() == Keyboard::KeyPressed);
	else if (l_kevent.key() == Keyboard::KBK_RIGHT)
		right(l_kevent.action() == Keyboard::KeyPressed);

	return(false);
}
コード例 #6
0
ファイル: demo0.cpp プロジェクト: gamaral/marshmallow_demos
	VIRTUAL bool handleEvent(const Event::IEvent &e)
	{
		using namespace Input;

		if (EngineBase::handleEvent(e))
			return(true);

		if (e.type() != Event::KeyboardEvent::Type())
			return(false);

		const Event::KeyboardEvent &l_kevent =
		    static_cast<const Event::KeyboardEvent &>(e);

		if (l_kevent.action() != Keyboard::KeyPressed)
			return(false);

		if (l_kevent.key() == Keyboard::KBK_ESCAPE ||
                    l_kevent.key() == Keyboard::KBK_P) {
			stop();
		} else return(false);

		return(true);
	}