本文整理匯總了Java中org.newdawn.slick.Input.isKeyDown方法的典型用法代碼示例。如果您正苦於以下問題:Java Input.isKeyDown方法的具體用法?Java Input.isKeyDown怎麽用?Java Input.isKeyDown使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.newdawn.slick.Input
的用法示例。
在下文中一共展示了Input.isKeyDown方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: otherKeyPress
import org.newdawn.slick.Input; //導入方法依賴的package包/類
/**
* If user press a new button, this method memorizes it.
* @param input
* @param n
* @return
*/
public boolean otherKeyPress(Input input, int n) {
if ((input.isKeyDown(comands[1])) && checkBlockDown() && comands[1] != n)
return true;
else if ((input.isKeyDown(comands[0])) && checkBlockUp() && comands[0] != n)
return true;
else if ((input.isKeyDown(comands[2])) && checkBlockLeft() && comands[2] != n)
return true;
else if((input.isKeyDown(comands[3])) && checkBlockRight() && comands[3] != n)
return true;
else
return false;
}
示例2: manualMovement
import org.newdawn.slick.Input; //導入方法依賴的package包/類
/**
* This method moves the character on the map based on the input
* @param input send by the keybord from user
*/
public void manualMovement(Input input){
setControlKeys();
setCorners();
if ((input.isKeyDown(comands[0]) || memButton == 1) && checkBlockUp()){
memButton = 1;
if (otherKeyPress(input, comands[0])){
memButton = 0;
}else{
y -= speed;
direction = Directions.UP;
}
}
if ((input.isKeyDown(comands[1]) || memButton == 2) && checkBlockDown()){
memButton = 2;
if (otherKeyPress(input, comands[1])){
memButton = 0;
}else{
y += speed;
direction = Directions.DOWN;
}
}
if ((input.isKeyDown(comands[2]) || memButton == 3) && checkBlockLeft()){
memButton = 3;
if (otherKeyPress(input, comands[2])){
memButton = 0;
}else{
x -= speed;
direction = Directions.LEFT;
}
if (checkTunnelLeft())
x = tileWidth * (mapWidth - 1);
}
if (((input.isKeyDown(comands[3]) || memButton == 4) && checkBlockRight())){
memButton = 4;
if (otherKeyPress(input, comands[3])){
memButton = 0;
}else{
x += speed;
direction = Directions.RIGHT;
}
if (checkTunnelRight())
x = 0;
}
}