本文整理汇总了Java中com.jogamp.newt.opengl.GLWindow.getY方法的典型用法代码示例。如果您正苦于以下问题:Java GLWindow.getY方法的具体用法?Java GLWindow.getY怎么用?Java GLWindow.getY使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jogamp.newt.opengl.GLWindow
的用法示例。
在下文中一共展示了GLWindow.getY方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readMouse
import com.jogamp.newt.opengl.GLWindow; //导入方法依赖的package包/类
/**
* Determines how far the mouse moved from the center and resets the mouse to the center.
* The information can be retrieved with {@code getMouseX()} and {@code getMouseY()}.
* @see #getMouseX
* @see #getMouseY
*/
public void readMouse() {
GLWindow win = c.getWindow();
if (win.hasFocus() && focused) {
Point mousePos = MouseInfo.getPointerInfo().getLocation();
int centerX = win.getX() + win.getWidth()/2;
int centerY = win.getY() + win.getHeight()/2;
mouseX = (mousePos.getX()-centerX)*mouseSensitivity;
mouseY = (mousePos.getY()-centerY)*mouseSensitivity;
robot.mouseMove(centerX, centerY);
} else {
setFocused(false);
mouseX = 0;
mouseY = 0;
}
}
示例2: setFocused
import com.jogamp.newt.opengl.GLWindow; //导入方法依赖的package包/类
private void setFocused(boolean focused) {
GLWindow win = c.getWindow();
this.focused = focused;
if (focused) {
win.setPointerVisible(false);
//Prevent sudden direction changes by resetting the mouse
int centerX = win.getX() + win.getWidth()/2;
int centerY = win.getY() + win.getHeight()/2;
robot.mouseMove(centerX, centerY);
} else {
win.setPointerVisible(true);
}
}
示例3: keyPressed
import com.jogamp.newt.opengl.GLWindow; //导入方法依赖的package包/类
/**
* Updates the keys based on the event received by the component.
*/
public void keyPressed(KeyEvent e) {
if (e.isAutoRepeat()) return;
if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
c.exit();
}
if (e.getKeyCode() == KeyEvent.VK_BACK_SPACE) {
if (focused)
setFocused(false);
}
if (e.getKeyCode() == KeyEvent.VK_F11) {
c.toggleFullscreen();
if (focused) {
//Prevent sudden direction changes by resetting the mouse
GLWindow win = c.getWindow();
int centerX = win.getX() + win.getWidth()/2;
int centerY = win.getY() + win.getHeight()/2;
robot.mouseMove(centerX, centerY);
}
}
//Handle keys
for (int i=0; i<NUM_KEYS; i++) {
if (e.getKeyCode() == keyCode[i]) {
if (!keyDown[i]) keyHelper[i] = true;
keyDown[i] = true;
}
}
}