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


Java Mouse.getEventButtonState方法代码示例

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


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

示例1: 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();
			}
		}
	}
}
 
开发者ID:hungthuanmk,项目名称:HCMIU_PlantsAndZombies,代码行数:22,代码来源:GameOver.java

示例2: 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();
			}
		}
	}
}
 
开发者ID:hungthuanmk,项目名称:HCMIU_PlantsAndZombies,代码行数:24,代码来源:PlayUI.java

示例3: 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));
	}
	
}
 
开发者ID:hungthuanmk,项目名称:HCMIU_PlantsAndZombies,代码行数:30,代码来源:PlayUI.java

示例4: handleMouseInput

import org.lwjgl.input.Mouse; //导入方法依赖的package包/类
public void handleMouseInput()
{
    if(Mouse.getEventButtonState())
    {
        int i = (Mouse.getEventX() * width) / mc.displayWidth;
        int k = height - (Mouse.getEventY() * height) / mc.displayHeight - 1;
        mouseClicked(i, k, Mouse.getEventButton());
    } else
    {
        int j = (Mouse.getEventX() * width) / mc.displayWidth;
        int l = height - (Mouse.getEventY() * height) / mc.displayHeight - 1;
        mouseMovedOrUp(j, l, Mouse.getEventButton());
    }
}
 
开发者ID:jd-lang,项目名称:betaexpansion,代码行数:15,代码来源:GuiScreen.java

示例5: 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();
}
 
开发者ID:p455w0rd,项目名称:DankNull,代码行数:30,代码来源:GuiDankNull.java

示例6: 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();
}
 
开发者ID:fr1kin,项目名称:ForgeHax,代码行数:41,代码来源:MinecraftGuiProxy.java

示例7: 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);
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:37,代码来源:GuiScreen.java

示例8: handleMouseInput

import org.lwjgl.input.Mouse; //导入方法依赖的package包/类
public void handleMouseInput()
{
    super.handleMouseInput();

    if (this.scrollMultiplier > 0.0F && Mouse.getEventButtonState())
    {
        this.field_178046_u.customMouseEvent(this.top, this.bottom, this.headerPadding, this.amountScrolled, this.slotHeight);
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:10,代码来源:GuiClickableScrolledSelectionListProxy.java

示例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();
    }
}
 
开发者ID:OCDiary,项目名称:Twitchy,代码行数:15,代码来源:TCDrawScreen.java

示例10: handleMouseInput

import org.lwjgl.input.Mouse; //导入方法依赖的package包/类
public void handleMouseInput()
{
    super.handleMouseInput();

    if (this.scrollMultiplier > 0.0F && Mouse.getEventButtonState())
    {
        this.proxy.customMouseEvent(this.top, this.bottom, this.headerPadding, this.amountScrolled, this.slotHeight);
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:10,代码来源:GuiClickableScrolledSelectionListProxy.java

示例11: 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();
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:12,代码来源:MouseEvent.java

示例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();
            }
        }
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:64,代码来源:Minecraft.java

示例13: 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();
            }
        }
    }
}
 
开发者ID:NSExceptional,项目名称:Zombe-Modpack,代码行数:62,代码来源:Minecraft.java


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