當前位置: 首頁>>代碼示例>>Java>>正文


Java Input類代碼示例

本文整理匯總了Java中org.newdawn.slick.Input的典型用法代碼示例。如果您正苦於以下問題:Java Input類的具體用法?Java Input怎麽用?Java Input使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Input類屬於org.newdawn.slick包,在下文中一共展示了Input類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: keyPressed

import org.newdawn.slick.Input; //導入依賴的package包/類
/**
 * @see org.newdawn.slick.BasicGame#keyPressed(int, char)
 */
public void keyPressed(int key, char c) {
	if (key == Input.KEY_ESCAPE) {
		System.exit(0);
	}
	
	if(key == Input.KEY_N) {
		curTest++;
		curTest %= NUMTESTS;
	}
	
	if(key == Input.KEY_C) {
		colorIndex++;
		
		colorIndex %= 4;
		setColors();
	}
	
	if(key == Input.KEY_T) {
		hideOverlay = !hideOverlay;
	}

}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:26,代碼來源:GeomAccuracyTest.java

示例2: MouseOverArea

import org.newdawn.slick.Input; //導入依賴的package包/類
/**
 * Create a new mouse over area
 * 
 * @param container
 *            The container displaying the mouse over area
 * @param image
 *            The normalImage to display
 * @param shape
 *            The shape defining the area of the mouse sensitive zone
 */
public MouseOverArea(GUIContext container, Image image, Shape shape) {
	super(container);

	area = shape;
	normalImage = image;
	currentImage = image;
	mouseOverImage = image;
	mouseDownImage = image;

	currentColor = normalColor;

	state = NORMAL;
	Input input = container.getInput();
	over = area.contains(input.getMouseX(), input.getMouseY());
	mouseDown = input.isMouseButtonDown(0);
	updateImage();
}
 
開發者ID:IngSW-unipv,項目名稱:Progetto-C,代碼行數:28,代碼來源:MouseOverArea.java

示例3: keyReleased

import org.newdawn.slick.Input; //導入依賴的package包/類
/**
 * @see org.newdawn.slick.BasicGame#keyReleased(int, char)
 */
public void keyReleased(int key, char c) {
   if (key == Input.KEY_Q) {
      scaleUp = false;
   }
   if (key == Input.KEY_A) {
      scaleDown = false;
   }
   
   if( key == Input.KEY_LEFT) {
      moveLeft = false;
   }
   if( key == Input.KEY_UP ) {
      moveUp = false;
   }
   if( key == Input.KEY_RIGHT ) {
      moveRight = false;
   }
   if( key == Input.KEY_DOWN ) {
      moveDown = false;
   }
}
 
開發者ID:j-dong,項目名稱:trashjam2017,代碼行數:25,代碼來源:TransformTest2.java

示例4: keyReleased

import org.newdawn.slick.Input; //導入依賴的package包/類
/**
 * @see org.newdawn.slick.state.BasicGameState#keyReleased(int, char)
 */
public void keyReleased(int key, char c) {
	if (key == Input.KEY_DOWN) {
		selected++;
		if (selected >= options.length) {
			selected = 0;
		}
	}
	if (key == Input.KEY_UP) {
		selected--;
		if (selected < 0) {
			selected = options.length - 1;
		}
	}
	if (key == Input.KEY_1) {
		game.enterState(TestState1.ID, new FadeOutTransition(Color.black), new FadeInTransition(Color.black));
	}
	if (key == Input.KEY_2) {
		game.enterState(TestState2.ID, new FadeOutTransition(Color.black), new FadeInTransition(Color.black));
	}
}
 
開發者ID:j-dong,項目名稱:trashjam2017,代碼行數:24,代碼來源:TestState3.java

示例5: update

import org.newdawn.slick.Input; //導入依賴的package包/類
/**
 * @see org.newdawn.slick.BasicGame#update(org.newdawn.slick.GameContainer, int)
 */
public void update(GameContainer container, int delta) {
       lshift = container.getInput().isKeyDown(Input.KEY_LSHIFT);
       rshift = container.getInput().isKeyDown(Input.KEY_RSHIFT);
       space = container.getInput().isKeyDown(Input.KEY_SPACE); 
       
	if (controllerLeft[0]) {
		x -= delta * 0.1f;
	}
	if (controllerRight[0]) {
		x += delta * 0.1f;
	}
	if (controllerUp[0]) {
		y -= delta * 0.1f;
	}
	if (controllerDown[0]) {
		y += delta * 0.1f;
	}
}
 
開發者ID:j-dong,項目名稱:trashjam2017,代碼行數:22,代碼來源:InputTest.java

示例6: update

import org.newdawn.slick.Input; //導入依賴的package包/類
@Override
public void update(GameContainer gc, StateBasedGame sbg, int i) throws SlickException {
    if (shouldToggleFullscreen) {
        shouldToggleFullscreen = false;
        boolean fs = !gc.isFullscreen();
        AppGameContainer agc = (AppGameContainer)gc;
        agc.setDisplayMode(fs ? agc.getScreenWidth() : Application.DISPLAY_WIDTH,
                           fs ? agc.getScreenHeight() : Application.DISPLAY_HEIGHT, fs);
    }
    if (gc.getInput().isKeyPressed(Input.KEY_ENTER)) {
        click.play(1.0f, CLICK_VOLUME);
        mainMenu.fade(1000, 0.0f, true);
        sbg.enterState(Application.GAME, new FadeOutTransition(Color.black, 1000), new EmptyTransition());
    }
    if (gc.getInput().isKeyPressed(Input.KEY_C)) {
        sbg.enterState(Application.CREDITS);
    }
}
 
開發者ID:j-dong,項目名稱:trashjam2017,代碼行數:19,代碼來源:MainMenu.java

示例7: update

import org.newdawn.slick.Input; //導入依賴的package包/類
/**
 * @see org.newdawn.slick.BasicGame#update(org.newdawn.slick.GameContainer, int)
 */
public void update(GameContainer container, int delta) throws SlickException {
	ang += delta * 0.1f;
	
	if (container.getInput().isKeyDown(Input.KEY_LEFT)) {
		x -= delta * 0.1f;
	}
	if (container.getInput().isKeyDown(Input.KEY_RIGHT)) {
		x += delta * 0.1f;
	}
	if (container.getInput().isKeyDown(Input.KEY_UP)) {
		y -= delta * 0.1f;
	}
	if (container.getInput().isKeyDown(Input.KEY_DOWN)) {
		y += delta * 0.1f;
	}
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:20,代碼來源:BigImageTest.java

示例8: keyPressed

import org.newdawn.slick.Input; //導入依賴的package包/類
/**
 * @see org.newdawn.slick.BasicGame#keyPressed(int, char)
 */
public void keyPressed(int key, char c) {
	if (key == Input.KEY_ESCAPE) {
		System.exit(0);
	}
	if (key == Input.KEY_F2) {
		app.setDefaultMouseCursor();
	}
	if (key == Input.KEY_F1) {
		if (app != null) {
			try {
				app.setDisplayMode(640,480,false);		
			} catch (SlickException e) {
				Log.error(e);
			}
		}
	}
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:21,代碼來源:GUITest.java

示例9: keyPressed

import org.newdawn.slick.Input; //導入依賴的package包/類
/**
 * @see org.newdawn.slick.BasicGame#keyPressed(int, char)
 */
public void keyPressed(int key, char c) {
   if (key == Input.KEY_ESCAPE) {
      System.exit(0);
   }
   if (key == Input.KEY_Q) {
      scaleUp = true;
   }
   if (key == Input.KEY_A) {
      scaleDown = true;
   }

   if( key == Input.KEY_LEFT) {
      moveLeft = true;
   }
   if( key == Input.KEY_UP ) {
      moveUp = true;
   }
   if( key == Input.KEY_RIGHT ) {
      moveRight = true;
   }
   if( key == Input.KEY_DOWN ) {
      moveDown = true;
   }
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:28,代碼來源:TransformTest2.java

示例10: keyReleased

import org.newdawn.slick.Input; //導入依賴的package包/類
@Override
public void keyReleased(int key, char c) {
	if(key == Input.KEY_GRAVE) {
		console.setPauseTime(time);
		consoleOpen = !consoleOpen;
	}
	else if((key == Input.KEY_P) && !consoleOpen) {
		if(!paused) MusicPlayer.getInstance().pause();
		else MusicPlayer.getInstance().resume();
		paused = !paused;
	}
	else {
		if(consoleOpen) {
			console.keyReleased(key, c);
		} else {
			Globals.inputs.remove(key);
			Globals.released.add(key);
		}
	}
}
 
開發者ID:packetpirate,項目名稱:Generic-Zombie-Shooter-Redux,代碼行數:21,代碼來源:GameState.java

示例11: keyPressed

import org.newdawn.slick.Input; //導入依賴的package包/類
/**
 * @see org.newdawn.slick.BasicGame#keyPressed(int, char)
 */
public void keyPressed(int key, char c) {
	if (key == Input.KEY_ESCAPE) {
		System.exit(0);
	}
	if (key == Input.KEY_Q) {
		scaleUp = true;
	}
	if (key == Input.KEY_A) {
		scaleDown = true;
	}
}
 
開發者ID:j-dong,項目名稱:trashjam2017,代碼行數:15,代碼來源:TransformTest.java

示例12: keyPressed

import org.newdawn.slick.Input; //導入依賴的package包/類
/**
 * @see org.newdawn.slick.BasicGame#keyPressed(int, char)
 */
public void keyPressed(int key, char c) {
	if (key == Input.KEY_ESCAPE) {
		System.exit(0);
	}
	if (key == Input.KEY_SPACE) {
		visible = !visible;
	}
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:12,代碼來源:TrueTypeFontPerformanceTest.java

示例13: update

import org.newdawn.slick.Input; //導入依賴的package包/類
/**
 * @see org.newdawn.slick.BasicGame#update(org.newdawn.slick.GameContainer, int)
 */
public void update(GameContainer container, int delta) throws SlickException {
	fire.update(delta);
	
	if (container.getInput().isKeyPressed(Input.KEY_P)) {
		writeTo("ImageOutTest.png");
	}
	if (container.getInput().isKeyPressed(Input.KEY_J)) {
		writeTo("ImageOutTest.jpg");
	}
	if (container.getInput().isKeyPressed(Input.KEY_T)) {
		writeTo("ImageOutTest.tga");
	}
}
 
開發者ID:j-dong,項目名稱:trashjam2017,代碼行數:17,代碼來源:ImageOutTest.java

示例14: keyPressed

import org.newdawn.slick.Input; //導入依賴的package包/類
/**
 * @see org.newdawn.slick.BasicGame#keyPressed(int, char)
 */
public void keyPressed(int key, char c) {
	if (key == Input.KEY_SPACE) {
		if (image == gif) {
			image = tga;
		} else {
			image = gif;
		}
	}
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:13,代碼來源:ImageTest.java

示例15: keyPressed

import org.newdawn.slick.Input; //導入依賴的package包/類
/**
 * @see org.newdawn.slick.BasicGame#keyPressed(int, char)
 */
public void keyPressed(int key, char c) {
	currentGame.keyPressed(key, c);
	
	if (key == Input.KEY_ENTER) {
		nextGame();
	}
}
 
開發者ID:j-dong,項目名稱:trashjam2017,代碼行數:11,代碼來源:TestBox.java


注:本文中的org.newdawn.slick.Input類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。