本文整理匯總了Java中com.jme3.input.KeyInput.KEY_5屬性的典型用法代碼示例。如果您正苦於以下問題:Java KeyInput.KEY_5屬性的具體用法?Java KeyInput.KEY_5怎麽用?Java KeyInput.KEY_5使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類com.jme3.input.KeyInput
的用法示例。
在下文中一共展示了KeyInput.KEY_5屬性的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: isNumberKey
/**
*
* @param kie
* @return
*/
public static boolean isNumberKey(KeyInputEvent kie) {
switch (kie.getKeyCode()) {
case KeyInput.KEY_MINUS:
case KeyInput.KEY_0:
case KeyInput.KEY_1:
case KeyInput.KEY_2:
case KeyInput.KEY_3:
case KeyInput.KEY_4:
case KeyInput.KEY_5:
case KeyInput.KEY_6:
case KeyInput.KEY_7:
case KeyInput.KEY_8:
case KeyInput.KEY_9:
case KeyInput.KEY_NUMPAD0:
case KeyInput.KEY_NUMPAD1:
case KeyInput.KEY_NUMPAD2:
case KeyInput.KEY_NUMPAD3:
case KeyInput.KEY_NUMPAD4:
case KeyInput.KEY_NUMPAD5:
case KeyInput.KEY_NUMPAD6:
case KeyInput.KEY_NUMPAD7:
case KeyInput.KEY_NUMPAD8:
case KeyInput.KEY_NUMPAD9:
case KeyInput.KEY_PERIOD:
return true;
}
return false;
}
示例2: setNumberKey
/**
* store the number kie into the numberBuilder
*
* @param kie the KeiInputEvent to be handled as a number.
* @param numberBuilder the number builder that will be modified !
*/
public static void setNumberKey(KeyInputEvent kie, StringBuilder numberBuilder) {
switch (kie.getKeyCode()) {
case KeyInput.KEY_MINUS:
if (numberBuilder.length() > 0) {
if (numberBuilder.charAt(0) == '-') {
numberBuilder.replace(0, 1, "");
} else {
numberBuilder.insert(0, '-');
}
} else {
numberBuilder.append('-');
}
break;
case KeyInput.KEY_0:
case KeyInput.KEY_1:
case KeyInput.KEY_2:
case KeyInput.KEY_3:
case KeyInput.KEY_4:
case KeyInput.KEY_5:
case KeyInput.KEY_6:
case KeyInput.KEY_7:
case KeyInput.KEY_8:
case KeyInput.KEY_9:
case KeyInput.KEY_NUMPAD0:
case KeyInput.KEY_NUMPAD1:
case KeyInput.KEY_NUMPAD2:
case KeyInput.KEY_NUMPAD3:
case KeyInput.KEY_NUMPAD4:
case KeyInput.KEY_NUMPAD5:
case KeyInput.KEY_NUMPAD6:
case KeyInput.KEY_NUMPAD7:
case KeyInput.KEY_NUMPAD8:
case KeyInput.KEY_NUMPAD9:
numberBuilder.append(kie.getKeyChar());
break;
case KeyInput.KEY_PERIOD:
if (numberBuilder.indexOf(".") == -1) { // if it doesn't exist yet
if (numberBuilder.length() == 0
|| (numberBuilder.length() == 1 && numberBuilder.charAt(0) == '-')) {
numberBuilder.append("0.");
} else {
numberBuilder.append(".");
}
}
break;
}
}