本文整理汇总了Java中org.lwjgl.input.Mouse.isButtonDown方法的典型用法代码示例。如果您正苦于以下问题:Java Mouse.isButtonDown方法的具体用法?Java Mouse.isButtonDown怎么用?Java Mouse.isButtonDown使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.lwjgl.input.Mouse
的用法示例。
在下文中一共展示了Mouse.isButtonDown方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: render
import org.lwjgl.input.Mouse; //导入方法依赖的package包/类
@Override
public void render(int mouseX, int mouseY, float partialTick) {
GL11.glColor4d(1, 1, 1, 1);
if (!Mouse.isButtonDown(0)) dragging = false;
if (!wasClicking && Mouse.isButtonDown(0) && getBounds().contains(mouseX, mouseY)) {
dragging = true;
}
if (!enabled) dragging = false;
wasClicking = Mouse.isButtonDown(0);
if (dragging) currentScroll = (float) (mouseY - 7 - getBounds().y) / (getBounds().height - 17);
currentScroll = MathHelper.clamp(currentScroll, 0, 1);
Minecraft.getMinecraft().getTextureManager().bindTexture(scrollTexture);
Gui.drawModalRectWithCustomSizedTexture(x, y, 12, 0, getBounds().width, 1, 26, 15);
for (int i = 0; i < getBounds().height - 2; i++)
Gui.drawModalRectWithCustomSizedTexture(x, y + 1 + i, 12, 1, getBounds().width, 1, 26, 15);
Gui.drawModalRectWithCustomSizedTexture(x, y + getBounds().height - 1, 12, 14, getBounds().width, 1, 26, 15);
if (!enabled) GL11.glColor4d(0.6, 0.6, 0.6, 1);
Gui.drawModalRectWithCustomSizedTexture(x + 1, y + 1 + (int) ((getBounds().height - 17) * currentScroll), 0, 0, 12, 15, 26, 15);
GL11.glColor4d(1, 1, 1, 1);
}
示例2: update
import org.lwjgl.input.Mouse; //导入方法依赖的package包/类
public void update(float contentSize, float mouseX, float mouseY, VectorUtil position) {
this.position = position;
windowContentRatio = windowSize / contentSize;
gripSize = MathUtil.clamp(trackSize * windowContentRatio, 10, trackSize);
gripPosY = (trackSize - gripSize) * (offset / (contentSize - windowSize));
if (mouseOverTrack(mouseX, mouseY) && Mouse.isButtonDown(0))
scrolling = true;
else if (!Mouse.isButtonDown(0))
scrolling = false;
float delta = scrolling ? mouseY - oldMouseY : -scrollVelocity;
float trackScrollArea = trackSize - gripSize;
float newGripPosY = MathUtil.clamp(gripPosY + delta, 0, trackScrollArea);
float gripPosRatio = newGripPosY / trackScrollArea;
offset = gripPosRatio * ((windowSize / windowContentRatio) - windowSize);
scrollVelocity = 0;
oldMouseY = mouseY;
}
示例3: startButton
import org.lwjgl.input.Mouse; //导入方法依赖的package包/类
public void startButton(GameContainer gc, StateBasedGame sbg, Graphics g) throws SlickException {
float rate = 0.9f;
float width = playButton.getWidth() * PZGUI.getResolutionRateWidth() * rate;
float height = playButton.getHeight() * PZGUI.getResolutionRateHeight() * rate;
float posX = PZGUI.getWidth() /2 - width/2;
float posY = PZGUI.getHeight() * (float)(0.7) - height/2;
float edgeX = posX + width;
float edgeY = posY + height;
playButton.draw(posX, posY, width, height);
if ( Mouse.getX() >= posX &&
Mouse.getX() <= edgeX &&
PZGUI.getHeight() - Mouse.getY() >= posY &&
PZGUI.getHeight() - Mouse.getY() <= edgeY) {
playButton.draw(posX, posY, width, height, new Color(100, 100, 100, 60));
if (Mouse.isButtonDown(0))
sbg.enterState(1);
}
}
示例4: anyMouseDown
import org.lwjgl.input.Mouse; //导入方法依赖的package包/类
/**
* Check if any mouse button is down
*
* @return True if any mouse button is down
*/
private boolean anyMouseDown() {
for (int i=0;i<3;i++) {
if (Mouse.isButtonDown(i)) {
return true;
}
}
return false;
}
示例5: updateScreen
import org.lwjgl.input.Mouse; //导入方法依赖的package包/类
@Override
public void updateScreen()
{
if(!hasClicked)
{
rotateX += 2.5F;
releasedMouse = releasedMouse || !Mouse.isButtonDown(0);
}
}
示例6: calculatePitch
import org.lwjgl.input.Mouse; //导入方法依赖的package包/类
private void calculatePitch() {
if (Mouse.isButtonDown(1)) {
float pitchChange = Mouse.getDY() * 0.1f;
pitch -= pitchChange;
if (pitch > 90)
pitch = 90;
}
}
示例7: onPostUpdate
import org.lwjgl.input.Mouse; //导入方法依赖的package包/类
@EventTarget
private void onPostUpdate(UpdateEvent event) {
if (event.state == Event.State.POST && (autoclicker && Mouse.isButtonDown((int)0) || !autoclicker) && this.mc.objectMouseOver != null && this.mc.objectMouseOver.entityHit != null && this.attackChecks(this.mc.objectMouseOver.entityHit) && this.timer.delay((float)(1000.0 / this.speed))) {
if (this.criticals) {
this.crit();
}
this.mc.thePlayer.swingItem();
this.mc.thePlayer.sendQueue.addToSendQueue((Packet)new C02PacketUseEntity(this.mc.objectMouseOver.entityHit, C02PacketUseEntity.Action.ATTACK));
this.timer.reset();
}
}
示例8: clickOn
import org.lwjgl.input.Mouse; //导入方法依赖的package包/类
protected void clickOn() {
if (Mouse.getX() >= posX && Mouse.getX() <= posX + width && PZGUI.getHeight() - Mouse.getY() >= posY && PZGUI.getHeight() - Mouse.getY() <= posY + height) {
if (Mouse.isButtonDown(0) && isClicked == false)
{
onClicked();
}
}
}
示例9: calculatePitch
import org.lwjgl.input.Mouse; //导入方法依赖的package包/类
/**
* Calculate the pitch and change the pitch if the user is moving the mouse
* up or down with the LMB pressed.
*/
private void calculatePitch() {
if (Mouse.isButtonDown(0)) {
float pitchChange = Mouse.getDY() * PITCH_SENSITIVITY;
pitch.increaseTarget(-pitchChange);
clampPitch();
}
pitch.update(1f / 60);
}
示例10: drawSubWindows
import org.lwjgl.input.Mouse; //导入方法依赖的package包/类
@Override
protected void drawSubWindows(int mouseX, int mouseY) {
int x = this.listX;
int y = this.listY + this.listScrollPosition;
for (Rule rule : this.entity.getRules()) {
boolean mouseOver =
(x < mouseX && mouseX < x + this.listWidth)
&& (y < mouseY && mouseY < y + this.entryHeight)
&& (listY < mouseY && mouseY < listY + this.listHeight)
;
if (!mouseDown && Mouse.isButtonDown(0) && mouseOver) {
this.mouseDown = true;
// We were clicked.
this.selectRule(rule);
}
if (!Mouse.isButtonDown(0))
mouseDown = false;
if (y > 0 && y < this.listY + this.listHeight) {
if (mouseOver) {
drawRect(x, y, x + listWidth, y + entryHeight, 0xFF999999);
}
String modeStr = "";
String nameStr = rule.getName();
modeStr = this.getUserPolicyMode(rule.getMode());
if ("<machines>".equals(rule.getName())) {
nameStr = "Default Machine Policy";
modeStr = this.getMachinePolicyMode(rule.getMode());
} else if ("<players>".equals(rule.getName())) {
nameStr = "Default User Policy";
}
if (this.entity.rootUser != null && this.entity.rootUser.equals(rule.getName())) {
modeStr = modeStr + " [root]";
}
this.fontRendererObj.drawString(
nameStr,
x + 2, y + 4,
0x000000
);
this.fontRendererObj.drawString(
modeStr,
x + 2, y + 16,
0x666666
);
}
y += this.entryHeight;
}
}
示例11: drawScreen
import org.lwjgl.input.Mouse; //导入方法依赖的package包/类
/**
* Draws the screen and all the components in it. Args : mouseX, mouseY, renderPartialTicks
*/
public void drawScreen(int mouseX, int mouseY, float partialTicks)
{
boolean flag = Mouse.isButtonDown(0);
int i = this.guiLeft;
int j = this.guiTop;
int k = i + 175;
int l = j + 18;
int i1 = k + 14;
int j1 = l + 112;
if (!this.wasClicking && flag && mouseX >= k && mouseY >= l && mouseX < i1 && mouseY < j1)
{
this.isScrolling = this.needsScrollBars();
}
if (!flag)
{
this.isScrolling = false;
}
this.wasClicking = flag;
if (this.isScrolling)
{
this.currentScroll = ((float)(mouseY - l) - 7.5F) / ((float)(j1 - l) - 15.0F);
this.currentScroll = MathHelper.clamp_float(this.currentScroll, 0.0F, 1.0F);
((GuiContainerCreative.ContainerCreative)this.inventorySlots).scrollTo(this.currentScroll);
}
super.drawScreen(mouseX, mouseY, partialTicks);
for (CreativeTabs creativetabs : CreativeTabs.creativeTabArray)
{
if (this.renderCreativeInventoryHoveringText(creativetabs, mouseX, mouseY))
{
break;
}
}
if (this.field_147064_C != null && selectedTabIndex == CreativeTabs.tabInventory.getTabIndex() && this.isPointInRegion(this.field_147064_C.xDisplayPosition, this.field_147064_C.yDisplayPosition, 16, 16, mouseX, mouseY))
{
this.drawCreativeTabHoveringText(I18n.format("inventory.binSlot", new Object[0]), mouseX, mouseY);
}
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
GlStateManager.disableLighting();
}
示例12: input
import org.lwjgl.input.Mouse; //导入方法依赖的package包/类
private void input() {
if (mouseEnabled || Mouse.isButtonDown(0)) {
mouseEnabled = true;
int mousex = Mouse.getX();
int mousey = 480 - Mouse.getY() - 1;
boolean mouseClicked = Mouse.isButtonDown(0);
selector_x = Math.round(mousex / World.BLOCK_SIZE);
selector_y = Math.round(mousey / World.BLOCK_SIZE);
if (mouseClicked) {
grid.setAt(selector_x, selector_y, selection);
}
}
while (Keyboard.next()) {
if (Keyboard.getEventKey() == Keyboard.KEY_RIGHT && Keyboard.getEventKeyState()) {
if (!(selector_x + 1 > World.BLOCKS_WIDTH - 2)) {
mouseEnabled = false;
selector_x++;
}
}
if (Keyboard.getEventKey() == Keyboard.KEY_LEFT && Keyboard.getEventKeyState()) {
if (!(selector_x - 1 < 0)) {
mouseEnabled = false;
selector_x--;
}
}
if (Keyboard.getEventKey() == Keyboard.KEY_UP && Keyboard.getEventKeyState()) {
if (!(selector_y - 1 < 0)) {
mouseEnabled = false;
selector_y--;
}
}
if (Keyboard.getEventKey() == Keyboard.KEY_DOWN && Keyboard.getEventKeyState()) {
if (!(selector_y + 1 > World.BLOCKS_HEIGHT - 2)) {
mouseEnabled = false;
selector_y++;
}
}
if (Keyboard.getEventKey() == Keyboard.KEY_S) {
grid.save(new File("save.xml"));
}
if (Keyboard.getEventKey() == Keyboard.KEY_L) {
grid.load(new File("save.xml"));
}
if (Keyboard.getEventKey() == Keyboard.KEY_1) {
selection = BlockType.STONE;
}
if (Keyboard.getEventKey() == Keyboard.KEY_2) {
selection = BlockType.DIRT;
}
if (Keyboard.getEventKey() == Keyboard.KEY_3) {
selection = BlockType.GRASS;
}
if (Keyboard.getEventKey() == Keyboard.KEY_4) {
selection = BlockType.AIR;
}
if (Keyboard.getEventKey() == Keyboard.KEY_C) {
grid.clear();
}
if (Keyboard.getEventKey() == Keyboard.KEY_SPACE) {
grid.setAt(selector_x, selector_y, selection);
}
if (Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) {
Display.destroy();
System.exit(0);
}
}
}
示例13: calculatePan
import org.lwjgl.input.Mouse; //导入方法依赖的package包/类
private void calculatePan() {
if (Mouse.isButtonDown(0) && Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)) {
cameraPosZ += Mouse.getDY() * -PAN_SENSITIVITY;
cameraPosX += Mouse.getDX() * PAN_SENSITIVITY;
}
}
示例14: drawListHeader
import org.lwjgl.input.Mouse; //导入方法依赖的package包/类
protected void drawListHeader(int p_148129_1_, int p_148129_2_, Tessellator p_148129_3_)
{
if (!Mouse.isButtonDown(0))
{
this.field_148218_l = -1;
}
if (this.field_148218_l == 0)
{
GuiStats.this.drawSprite(p_148129_1_ + 115 - 18, p_148129_2_ + 1, 0, 0);
}
else
{
GuiStats.this.drawSprite(p_148129_1_ + 115 - 18, p_148129_2_ + 1, 0, 18);
}
if (this.field_148218_l == 1)
{
GuiStats.this.drawSprite(p_148129_1_ + 165 - 18, p_148129_2_ + 1, 0, 0);
}
else
{
GuiStats.this.drawSprite(p_148129_1_ + 165 - 18, p_148129_2_ + 1, 0, 18);
}
if (this.field_148218_l == 2)
{
GuiStats.this.drawSprite(p_148129_1_ + 215 - 18, p_148129_2_ + 1, 0, 0);
}
else
{
GuiStats.this.drawSprite(p_148129_1_ + 215 - 18, p_148129_2_ + 1, 0, 18);
}
if (this.field_148217_o != -1)
{
int i = 79;
int j = 18;
if (this.field_148217_o == 1)
{
i = 129;
}
else if (this.field_148217_o == 2)
{
i = 179;
}
if (this.field_148215_p == 1)
{
j = 36;
}
GuiStats.this.drawSprite(p_148129_1_ + i, p_148129_2_ + 1, j, 0);
}
}
示例15: drawScreen
import org.lwjgl.input.Mouse; //导入方法依赖的package包/类
/**
* Draws the screen and all the components in it.
*/
public void drawScreen(int mouseX, int mouseY, float partialTicks)
{
boolean flag = Mouse.isButtonDown(0);
int i = this.guiLeft;
int j = this.guiTop;
int k = i + 175;
int l = j + 18;
int i1 = k + 14;
int j1 = l + 112;
if (!this.wasClicking && flag && mouseX >= k && mouseY >= l && mouseX < i1 && mouseY < j1)
{
this.isScrolling = this.needsScrollBars();
}
if (!flag)
{
this.isScrolling = false;
}
this.wasClicking = flag;
if (this.isScrolling)
{
this.currentScroll = ((float)(mouseY - l) - 7.5F) / ((float)(j1 - l) - 15.0F);
this.currentScroll = MathHelper.clamp_float(this.currentScroll, 0.0F, 1.0F);
((GuiContainerCreative.ContainerCreative)this.inventorySlots).scrollTo(this.currentScroll);
}
super.drawScreen(mouseX, mouseY, partialTicks);
int start = tabPage * 10;
int end = Math.min(CreativeTabs.CREATIVE_TAB_ARRAY.length, ((tabPage + 1) * 10) + 2);
if (tabPage != 0) start += 2;
boolean rendered = false;
for (CreativeTabs creativetabs : java.util.Arrays.copyOfRange(CreativeTabs.CREATIVE_TAB_ARRAY,start,end))
{
if (creativetabs == null) continue;
if (this.renderCreativeInventoryHoveringText(creativetabs, mouseX, mouseY))
{
rendered = true;
break;
}
}
if (!rendered && !renderCreativeInventoryHoveringText(CreativeTabs.SEARCH, mouseX, mouseY))
{
renderCreativeInventoryHoveringText(CreativeTabs.INVENTORY, mouseX, mouseY);
}
if (this.destroyItemSlot != null && selectedTabIndex == CreativeTabs.INVENTORY.getTabIndex() && this.isPointInRegion(this.destroyItemSlot.xDisplayPosition, this.destroyItemSlot.yDisplayPosition, 16, 16, mouseX, mouseY))
{
this.drawCreativeTabHoveringText(I18n.format("inventory.binSlot", new Object[0]), mouseX, mouseY);
}
if (maxPages != 0)
{
String page = String.format("%d / %d", tabPage + 1, maxPages + 1);
int width = fontRendererObj.getStringWidth(page);
GlStateManager.disableLighting();
this.zLevel = 300.0F;
itemRender.zLevel = 300.0F;
fontRendererObj.drawString(page, guiLeft + (xSize / 2) - (width / 2), guiTop - 44, -1);
this.zLevel = 0.0F;
itemRender.zLevel = 0.0F;
}
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
GlStateManager.disableLighting();
}