本文整理汇总了Java中org.lwjgl.input.Mouse.getEventButton方法的典型用法代码示例。如果您正苦于以下问题:Java Mouse.getEventButton方法的具体用法?Java Mouse.getEventButton怎么用?Java Mouse.getEventButton使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.lwjgl.input.Mouse
的用法示例。
在下文中一共展示了Mouse.getEventButton方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: showNewGameButton
import org.lwjgl.input.Mouse; //导入方法依赖的package包/类
private void showNewGameButton(StateBasedGame sbg, Graphics g) throws SlickException {
float rate = 1.14f;
float posX = 435 * PZGUI.getResolutionRateWidth();
float posY = 430 * PZGUI.getResolutionRateHeight();
float width = newGameButton.getWidth() * PZGUI.getResolutionRateWidth() * rate;
float height = newGameButton.getHeight() * PZGUI.getResolutionRateHeight() * rate;
newGameButton.draw(posX, posY, width, height);
if (Controller.mouseInArea(posX, posY, posX + width, posY + height)) {
newGameButton.draw(posX, posY, width, height, new Color(0, 0, 0, 100));
if (Mouse.getEventButtonState() && Mouse.getEventButton() == 0) {
SunUI.getSunManager().clear();
SunUI.setSunCollected(50);
SunUI.setFramePassed(0);
sbg.getState(2);
sbg.enterState(2);
try {
TimeUnit.MILLISECONDS.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
示例2: showExitGameButton
import org.lwjgl.input.Mouse; //导入方法依赖的package包/类
private void showExitGameButton(GameContainer gc, Graphics g) throws SlickException {
float rate = 1.14f;
float posX = 885 * PZGUI.getResolutionRateWidth();
float posY = 430 * PZGUI.getResolutionRateHeight();
float width = newGameButton.getWidth() * PZGUI.getResolutionRateWidth() * rate;
float height = newGameButton.getHeight() * PZGUI.getResolutionRateHeight() * rate;
exitGameButton.draw(posX, posY, width, height);
if (Controller.mouseInArea(posX, posY, posX + width, posY + height)) {
exitGameButton.draw(posX, posY, width, height, new Color(0, 0, 0, 100));
if (Mouse.getEventButtonState() && Mouse.getEventButton() == 0) {
gc.exit();
try {
TimeUnit.MILLISECONDS.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
示例3: showPauseButton
import org.lwjgl.input.Mouse; //导入方法依赖的package包/类
/**
* Draw Pause button
* @param gc GameContainer
* @param g Graphics
* @throws SlickException
*/
public static void showPauseButton(GameContainer gc, Graphics g) throws SlickException {
pauseButton.draw(pauseButtonPosX, pauseButtonPosY, pauseButtonWidth, pauseButtonHeight);
if (Controller.mouseInArea(pauseButtonPosX, pauseButtonPosY, pauseButtonPosX + pauseButtonHeight,
pauseButtonPosY + pauseButtonHeight)) {
pauseButton.draw(pauseButtonPosX, pauseButtonPosY, pauseButtonWidth, pauseButtonHeight, new Color(0, 0, 0, 50));
if (Mouse.getEventButtonState() && Mouse.getEventButton() == 0) {
gc.setPaused(!gc.isPaused());
try {
TimeUnit.MILLISECONDS.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
示例4: showSpeedUpButton
import org.lwjgl.input.Mouse; //导入方法依赖的package包/类
/**
* Show speedUp button
* @param gc GameContainer
* @param g Graphics
* @throws SlickException
*/
public static void showSpeedUpButton(GameContainer gc, Graphics g) throws SlickException {
speedUpButton.draw(speedUpButtonPosX, speedUpButtonPosY, speedUpButtonWidth, speedUpButtonHeight);
if (Controller.mouseInArea(speedUpButtonPosX, speedUpButtonPosY, speedUpButtonPosX + speedUpButtonWidth,
speedUpButtonPosY + speedUpButtonHeight)) {
speedUpButton.draw(speedUpButtonPosX, speedUpButtonPosY, speedUpButtonWidth, speedUpButtonHeight,
new Color(0, 0, 0, 50));
if (Mouse.getEventButtonState() && Mouse.getEventButton() == 0) {
gc.setTargetFrameRate(isSpeedUpClicked==false?180:60);
gc.setVSync(isSpeedUpClicked);
isSpeedUpClicked = !isSpeedUpClicked;
try {
TimeUnit.MILLISECONDS.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
if (isSpeedUpClicked == false) {
speedUpButton.draw(speedUpButtonPosX, speedUpButtonPosY, speedUpButtonWidth, speedUpButtonHeight, new Color(0, 0, 0, 100));
}
}
示例5: showShovel
import org.lwjgl.input.Mouse; //导入方法依赖的package包/类
/**
* Show Shovel button
* @param gc GameContainer
* @param g Graphics
*/
public static void showShovel(GameContainer gc, Graphics g) {
shovel.draw(shovelButtonPosX, shovelButtonPosY, shovelButtonWidth, shovelButtonHeight);
if (Controller.mouseInArea(shovelButtonPosX, shovelButtonPosY, shovelButtonPosX + shovelButtonWidth, shovelButtonPosY + shovelButtonHeight)) {
shovel.draw(shovelButtonPosX, shovelButtonPosY, shovelButtonWidth, shovelButtonHeight, new Color(0, 0, 0, 100));
if (Mouse.getEventButtonState() && Mouse.getEventButton() == 0) {
isShovelClicked = !isShovelClicked;
try {
TimeUnit.MILLISECONDS.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
if (isShovelClicked) {
shovel.draw(Controller.getMouseX() - (20 * PZGUI.getResolutionRateWidth()),
Controller.getMouseY() - (30 * PZGUI.getResolutionRateHeight()),
shovelButtonWidth,
shovelButtonHeight);
}
}
示例6: handleMouseInput
import org.lwjgl.input.Mouse; //导入方法依赖的package包/类
@Override
public void handleMouseInput() throws IOException {
int mouseX = Mouse.getEventX() * width / mc.displayWidth;
int mouseY = height - Mouse.getEventY() * height / mc.displayHeight - 1;
int button = Mouse.getEventButton();
if (Mouse.getEventButtonState()) {
//if (GuiScreen.isCtrlKeyDown()) {
if (GuiScreen.isAltKeyDown()) {
if (button == 0) {
Slot slot = getSlotAtPos(mouseX, mouseY);
if (slot != null && !slot.getStack().isEmpty()) {
if (!ItemUtils.areItemsEqual(DankNullUtils.getSelectedStack(getDankNullInventory()), slot.getStack())) {
int count = 0;
for (Slot slotHovered : inventorySlots.inventorySlots) {
count++;
if (slotHovered.equals(slot)) {
DankNullUtils.setSelectedStackIndex(getDankNullInventory(), (count - 1) - 36);
return;
}
}
}
}
}
//}
}
}
super.handleMouseInput();
}
示例7: handleMouseInput
import org.lwjgl.input.Mouse; //导入方法依赖的package包/类
@Override
public void handleMouseInput() throws IOException {
int mouseCode = Mouse.getEventButton();
if(mouseCode < 0 || mouseCode >= Mouse.getButtonCount()) return; // only allow number of buttons supported by mouse (for mouse event, 0 is not an unknown button)
InputEntry entry = inputs.computeIfAbsent(Keyboard.KEYBOARD_SIZE + 1 + mouseCode, i -> new InputEntry(InputEntry.MOUSE, mouseCode));
boolean down = Mouse.getEventButtonState();
long currentTimeMS = System.currentTimeMillis();
GuiMouseEvent.Type type;
if(entry.getTicks() < 0) { // initially pressed
if(!down) return; // stop executing if key hasnt been initially pressed AND the key is being released (double release event)
type = GuiMouseEvent.Type.PRESSED;
entry.setTimePressed(currentTimeMS); // update last click time
} else {
type = down ? GuiMouseEvent.Type.DOWN : GuiMouseEvent.Type.RELEASED;
}
// update ticks
entry.incrementTicks();
int[] mpos = getMousePos();
element.onMouseEvent(new GuiMouseEvent(
type,
mouseCode,
mpos[0], mpos[1],
Mouse.getEventDWheel(),
entry.getTime(),
currentTimeMS - entry.getTimePressed())
);
if(type == GuiMouseEvent.Type.RELEASED) {
entry.setTime(entry.getTimePressed());
entry.setTimePressed(-1);
entry.resetTicks(); // reset ticks after event
}
super.handleMouseInput();
}
示例8: handleMouseInput
import org.lwjgl.input.Mouse; //导入方法依赖的package包/类
/**
* Handles mouse input.
*/
public void handleMouseInput() throws IOException
{
int i = Mouse.getEventX() * this.width / this.mc.displayWidth;
int j = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight - 1;
int k = Mouse.getEventButton();
if (Mouse.getEventButtonState())
{
if (this.mc.gameSettings.touchscreen && this.touchValue++ > 0)
{
return;
}
this.eventButton = k;
this.lastMouseEvent = Minecraft.getSystemTime();
this.mouseClicked(i, j, this.eventButton);
}
else if (k != -1)
{
if (this.mc.gameSettings.touchscreen && --this.touchValue > 0)
{
return;
}
this.eventButton = -1;
this.mouseReleased(i, j, k);
}
else if (this.eventButton != -1 && this.lastMouseEvent > 0L)
{
long l = Minecraft.getSystemTime() - this.lastMouseEvent;
this.mouseClickMove(i, j, this.eventButton, l);
}
}
示例9: mouseClick
import org.lwjgl.input.Mouse; //导入方法依赖的package包/类
@SubscribeEvent
public static void mouseClick(GuiScreenEvent.MouseInputEvent.Pre event)
{
if(mc.player != null && Mouse.getEventButton() == 0 && Mouse.getEventButtonState()) {
//Get mouse position
ScaledResolution sr = new ScaledResolution(mc);
int srHeight = sr.getScaledHeight();
int mouseX = Mouse.getX() * sr.getScaledWidth() / mc.displayWidth;
int mouseY = srHeight - Mouse.getY() * srHeight / mc.displayHeight - 1;
if (twitchRect.contains(mouseX, mouseY))
openTwitchStream();
}
}
示例10: MouseEvent
import org.lwjgl.input.Mouse; //导入方法依赖的package包/类
public MouseEvent()
{
this.x = Mouse.getEventX();
this.y = Mouse.getEventY();
this.dx = Mouse.getEventDX();
this.dy = Mouse.getEventDY();
this.dwheel = Mouse.getEventDWheel();
this.button = Mouse.getEventButton();
this.buttonstate = Mouse.getEventButtonState();
this.nanoseconds = Mouse.getEventNanoseconds();
}
示例11: runTickMouse
import org.lwjgl.input.Mouse; //导入方法依赖的package包/类
private void runTickMouse() throws IOException
{
while (Mouse.next())
{
int i = Mouse.getEventButton();
KeyBinding.setKeyBindState(i - 100, Mouse.getEventButtonState());
if (Mouse.getEventButtonState())
{
if (this.player.isSpectator() && i == 2)
{
this.ingameGUI.getSpectatorGui().onMiddleClick();
}
else
{
KeyBinding.onTick(i - 100);
}
}
long j = getSystemTime() - this.systemTime;
if (j <= 200L)
{
int k = Mouse.getEventDWheel();
if (k != 0)
{
if (this.player.isSpectator())
{
k = k < 0 ? -1 : 1;
if (this.ingameGUI.getSpectatorGui().isMenuActive())
{
this.ingameGUI.getSpectatorGui().onMouseScroll(-k);
}
else
{
float f = MathHelper.clamp(this.player.capabilities.getFlySpeed() + (float)k * 0.005F, 0.0F, 0.2F);
this.player.capabilities.setFlySpeed(f);
}
}
else
{
this.player.inventory.changeCurrentItem(k);
}
}
if (this.currentScreen == null)
{
if (!this.inGameHasFocus && Mouse.getEventButtonState())
{
this.setIngameFocus();
}
}
else if (this.currentScreen != null)
{
this.currentScreen.handleMouseInput();
}
}
}
}
示例12: runTickMouse
import org.lwjgl.input.Mouse; //导入方法依赖的package包/类
private void runTickMouse() throws IOException
{
while (Mouse.next())
{
if (net.minecraftforge.client.ForgeHooksClient.postMouseEvent()) continue;
int i = Mouse.getEventButton();
KeyBinding.setKeyBindState(i - 100, Mouse.getEventButtonState());
if (Mouse.getEventButtonState())
{
if (this.thePlayer.isSpectator() && i == 2)
{
this.ingameGUI.getSpectatorGui().onMiddleClick();
}
else
{
KeyBinding.onTick(i - 100);
}
}
long j = getSystemTime() - this.systemTime;
if (j <= 200L)
{
int k = Mouse.getEventDWheel();
if (k != 0)
{
if (this.thePlayer.isSpectator())
{
k = k < 0 ? -1 : 1;
if (this.ingameGUI.getSpectatorGui().isMenuActive())
{
this.ingameGUI.getSpectatorGui().onMouseScroll(-k);
}
else
{
float f = MathHelper.clamp_float(this.thePlayer.capabilities.getFlySpeed() + (float)k * 0.005F, 0.0F, 0.2F);
this.thePlayer.capabilities.setFlySpeed(f);
}
}
else
{
this.thePlayer.inventory.changeCurrentItem(k);
}
}
if (this.currentScreen == null)
{
if (!this.inGameHasFocus && Mouse.getEventButtonState())
{
this.setIngameFocus();
}
}
else if (this.currentScreen != null)
{
this.currentScreen.handleMouseInput();
}
}
}
}