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


C++ KeyboardEvent::getButton方法代码示例

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


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

示例1: onKeyboardButtonPressed

	virtual void onKeyboardButtonPressed(Keyboard& source, const KeyboardEvent& e) {
		if(e.getButton() == KeyboardButtonType::KEY_F1) {
			std::cout << "Camera Position:" << std::endl <<
						 "          X: " << camera->position.x << std::endl <<
						 "          Y: " << camera->position.y << std::endl <<
						 "          Z: " << camera->position.z << std::endl <<
						 " X Rotation: " << camera->rotation.x << std::endl <<
						 " Y Rotation: " << camera->rotation.y << std::endl;
		}

		if(e.getButton() == KeyboardButtonType::KEY_F) {
			if(cameraLight->diffuse.r == 0) {
				cameraLight->diffuse = Color(1, 1, 1, 1);
			} else {
				cameraLight->diffuse = Color(0, 0, 0, 0);
			}
		}
		

		if(source.isPressed(KeyboardButtonType::KEY_CONTROL)) {
			if(e.getButton() == KeyboardButtonType::KEY_ADD) {
				this->setSize(this->getWidth() + 16, this->getHeight() + 12);
				std::cout << "Window enlarged!" << std::endl;

			} else if(e.getButton() == KeyboardButtonType::KEY_SUBTRACT) {
				this->setSize(this->getWidth() - 16, this->getHeight() - 12);
				std::cout << "Window shrinked!" << std::endl;

			} else if(e.getButton() == KeyboardButtonType::KEY_R) {
				this->setResizable(!this->isResizable());
				std::cout << "This window is " <<
					(this->isResizable() ? "now resizable." : "not resizable anymore.") <<
					std::endl;

			} else if(e.getButton() == KeyboardButtonType::KEY_I) {
				this->showWindowInformation();

			} else if(e.getButton() == KeyboardButtonType::KEY_Q) {
				showHelp();

			} else if(e.getButton() == KeyboardButtonType::KEY_X) {
				this->close();
				std::cout << "Window closed!" << std::endl;

			} else if(e.getButton() == KeyboardButtonType::KEY_H) {
				if(other == NULL) {
					std::cout <<
						"Can't hide the window, reason: There is no other window!" << std::endl <<
						"Use CTRL+X to close this window." << std::endl;
				} else if(!other->isVisible()) {
					std::cout <<
						"Can't hide the window, reason: The other window is not visible!" <<
						std::endl << "Use CTRL+S to show the other window." << std::endl;
				} else {
					this->hide();
					std::cout << "Window hidden!" << std::endl;
				}

			} else if(e.getButton() == KeyboardButtonType::KEY_S) {
				if(other == NULL) {
					std::cout << "Can't show the other window, reason: There is no other window!" <<
						std::endl;
				} else {
					other->show();
					std::cout << "Showing the other window!" << std::endl;
				}
			}
		}
	}
开发者ID:rynti,项目名称:openLima,代码行数:69,代码来源:main.cpp


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