• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Mouse类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中net.java.games.input.Mouse的典型用法代码示例。如果您正苦于以下问题:Java Mouse类的具体用法?Java Mouse怎么用?Java Mouse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Mouse类属于net.java.games.input包,在下文中一共展示了Mouse类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: update

import net.java.games.input.Mouse; //导入依赖的package包/类
@Override
public void update() {
	mousex = 0;
	mousey = 0;
	for (Mouse m : mousecontrollers) {
		m.poll();
		if (m.getX().getPollData() != 0 || m.getY().getPollData() != 0) {
			mousex += m.getX().getPollData();
			mousey += m.getY().getPollData();
		}
	}

	for (Keyboard k : keyboardcontrollers) {
		k.poll();
	}
	for (Controller c : gamepadcontrollers) {
		c.poll();
	}
}
 
开发者ID:tdc22,项目名称:JAwesomeEngine,代码行数:20,代码来源:JInputReader.java


示例2: updateControllers

import net.java.games.input.Mouse; //导入依赖的package包/类
public void updateControllers() {
	mousecontrollers.clear();
	keyboardcontrollers.clear();
	gamepadcontrollers.clear();

	Controller[] ca = ControllerEnvironment.getDefaultEnvironment().getControllers();
	for (Controller c : ca) {
		Type t = c.getType();
		if (t == Type.MOUSE)
			mousecontrollers.add((Mouse) c);
		if (t == Type.KEYBOARD)
			keyboardcontrollers.add((Keyboard) c);
		if (t == Type.GAMEPAD)
			gamepadcontrollers.add(c);
	}
}
 
开发者ID:tdc22,项目名称:JAwesomeEngine,代码行数:17,代码来源:JInputReader.java


示例3: pollDevice

import net.java.games.input.Mouse; //导入依赖的package包/类
public synchronized void pollDevice() throws IOException {
	if (!org.lwjgl.input.Mouse.isCreated())
		return;
	org.lwjgl.input.Mouse.poll();
	for (int i = 0; i < 3; i++)
		setButtonState(i);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:8,代码来源:LWJGLMouse.java


示例4: JInputReader

import net.java.games.input.Mouse; //导入依赖的package包/类
public JInputReader() {
	mousecontrollers = new ArrayList<Mouse>();
	keyboardcontrollers = new ArrayList<Keyboard>();
	gamepadcontrollers = new ArrayList<Controller>();

	mousex = 0;
	mousey = 0;

	keys = new HashMap<String, Key>();

	updateControllers();
	setupKeys();
}
 
开发者ID:tdc22,项目名称:JAwesomeEngine,代码行数:14,代码来源:JInputReader.java


示例5: setButtonState

import net.java.games.input.Mouse; //导入依赖的package包/类
private void setButtonState(int lwjgl_button) {
	Button button = map(lwjgl_button);
	if (button != null)
		button.setValue(org.lwjgl.input.Mouse.isButtonDown(lwjgl_button) ? 1 : 0);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:6,代码来源:LWJGLMouse.java


示例6: getNextDeviceEvent

import net.java.games.input.Mouse; //导入依赖的package包/类
protected synchronized boolean getNextDeviceEvent(Event event) throws IOException {
	if (!org.lwjgl.input.Mouse.isCreated())
		return false;
	while (true) {
		long nanos = org.lwjgl.input.Mouse.getEventNanoseconds();
		switch (event_state) {
			case EVENT_X:
				event_state = EVENT_Y;
				int dx = org.lwjgl.input.Mouse.getEventDX();
				if (dx != 0) {
					event.set(getX(), dx, nanos);
					return true;
				}
				break;
			case EVENT_Y:
				event_state = EVENT_WHEEL;
				/* We must negate the y coord since lwjgl uses the
				 * OpenGL coordinate system
				 */
				int dy = -org.lwjgl.input.Mouse.getEventDY();
				if (dy != 0) {
					event.set(getY(), dy, nanos);
					return true;
				}
				break;
			case EVENT_WHEEL:
				event_state = EVENT_BUTTON;
				int dwheel = org.lwjgl.input.Mouse.getEventDWheel();
				if (dwheel != 0) {
					event.set(getWheel(), dwheel, nanos);
					return true;
				}
				break;
			case EVENT_BUTTON:
				event_state = EVENT_DONE;
				int lwjgl_button = org.lwjgl.input.Mouse.getEventButton();
				if (lwjgl_button != -1) {
					Button button = map(lwjgl_button);
					if (button != null) {
						event.set(button, org.lwjgl.input.Mouse.getEventButtonState() ? 1f : 0f, nanos);
						return true;
					}
				}
				break;
			case EVENT_DONE:
				if (!org.lwjgl.input.Mouse.next())
					return false;
				event_state = EVENT_X;
				break;
			default:
				break;
		}
	}
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:55,代码来源:LWJGLMouse.java


示例7: isMouseButtonDown

import net.java.games.input.Mouse; //导入依赖的package包/类
@Override
public boolean isMouseButtonDown(String button) {
	Component mousebutton = null;
	for (Mouse m : mousecontrollers) {
		switch (button) {
		case ("Left"):
			mousebutton = m.getLeft();
			break;
		case ("Middle"):
			mousebutton = m.getMiddle();
			break;
		case ("Right"):
			mousebutton = m.getRight();
			break;
		case ("Last"):
			mousebutton = m.getBack();
			break;
		case ("0"):
			mousebutton = m.getComponents()[0];
			break;
		case ("1"):
			mousebutton = m.getComponents()[1];
			break;
		case ("2"):
			mousebutton = m.getComponents()[2];
			break;
		case ("3"):
			mousebutton = m.getComponents()[3];
			break;
		case ("4"):
			mousebutton = m.getComponents()[4];
			break;
		case ("5"):
			mousebutton = m.getComponents()[5];
			break;
		case ("6"):
			mousebutton = m.getComponents()[6];
			break;
		case ("7"):
			mousebutton = m.getComponents()[7];
			break;
		}

		if (mousebutton.getPollData() == 1)
			return true;
	}
	return false;
}
 
开发者ID:tdc22,项目名称:JAwesomeEngine,代码行数:49,代码来源:JInputReader.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java IteratorInt类代码示例发布时间:2022-05-23
下一篇:
Java WebDelegatingSubject类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap