本文整理匯總了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;
}
}
示例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();
}
示例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;
}
}
示例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));
}
}
示例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;
}
}
示例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);
}
}
示例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;
}
}
示例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);
}
}
}
}
示例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;
}
}
示例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);
}
}
}
示例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;
}
}
示例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;
}
}
示例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");
}
}
示例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;
}
}
}
示例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();
}
}