本文整理汇总了Java中net.java.games.input.Event.set方法的典型用法代码示例。如果您正苦于以下问题:Java Event.set方法的具体用法?Java Event.set怎么用?Java Event.set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.java.games.input.Event
的用法示例。
在下文中一共展示了Event.set方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getNextDeviceEvent
import net.java.games.input.Event; //导入方法依赖的package包/类
protected synchronized boolean getNextDeviceEvent(Event event) throws IOException {
if (!org.lwjgl.input.Keyboard.isCreated())
return false;
if (!org.lwjgl.input.Keyboard.next())
return false;
int lwjgl_key = org.lwjgl.input.Keyboard.getEventKey();
if (lwjgl_key == org.lwjgl.input.Keyboard.KEY_NONE)
return false;
Component.Identifier.Key key_id = KeyMap.map(lwjgl_key);
if (key_id == null)
return false;
Component key = getComponent(key_id);
if (key == null)
return false;
float value = org.lwjgl.input.Keyboard.getEventKeyState() ? 1 : 0;
event.set(key, value, org.lwjgl.input.Keyboard.getEventNanoseconds());
return true;
}
示例2: getNextDeviceEvent
import net.java.games.input.Event; //导入方法依赖的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;
}
}
}