本文整理汇总了Java中com.badlogic.gdx.controllers.PovDirection.ordinal方法的典型用法代码示例。如果您正苦于以下问题:Java PovDirection.ordinal方法的具体用法?Java PovDirection.ordinal怎么用?Java PovDirection.ordinal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.controllers.PovDirection
的用法示例。
在下文中一共展示了PovDirection.ordinal方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getInputDisplayName
import com.badlogic.gdx.controllers.PovDirection; //导入方法依赖的package包/类
public static String getInputDisplayName(int type, ConfigKeymap config, String key) {
ConfigKeymap.Input input = config.getInput(key, -1, -1, -1);
if (input.getInput() < 0)
return "NONE";
if (type == KEYBOARD && input.getInput() <= 255)
return Input.Keys.toString(input.getInput());
else if (type == CONTROLLER) {
if (input.getType() == ConfigKeymap.Input.TYPE_AXIS)
return String.format(Locale.US, "Axis %d %s", input.getInput(),
input.getExtra() == 0 ? "negative" : "positive");
else if (input.getType() == ConfigKeymap.Input.TYPE_POV) {
String pov = String.valueOf(input.getExtra());
for (PovDirection dir : PovDirection.values())
if (dir.ordinal() == input.getExtra())
pov = dir.name();
return String.format(Locale.US, "D-pad %d %s", input.getInput(), pov);
}
else if (input.getType() == ConfigKeymap.Input.TYPE_BUTTON)
return String.format(Locale.US, "Button %d", input.getInput());
}
return String.format(Locale.US, "%d", input.getInput());
}
示例2: povMoved
import com.badlogic.gdx.controllers.PovDirection; //导入方法依赖的package包/类
@Override
public boolean povMoved(Controller controller, int povCode, PovDirection dir) {
for(int i = 0; i<this.povDirections.length; i++) {
this.povDirections[i] = false;
}
this.povDirections[dir.ordinal()] = true;
return false;
}
示例3: pollInputController
import com.badlogic.gdx.controllers.PovDirection; //导入方法依赖的package包/类
private void pollInputController() {
int input = -1;
int input_extra = -1;
int input_type = -1;
main:
for (Controller controller : Controllers.getControllers()) {
if (!controller.getName().equals(this.controllerName))
continue;
// Check axes
for (int axis = 0; axis < 1000; axis++) {
float ax = controller.getAxis(axis);
if (ax > .5) {
input_type = ConfigKeymap.Input.TYPE_AXIS;
input = axis;
input_extra = 1; // positive
break main;
}
else if (ax < -.5) {
input_type = ConfigKeymap.Input.TYPE_AXIS;
input = axis;
input_extra = 0; // negative
break main;
}
}
// Only allow an axis to be set for joystick input.
// TODO Map all 4(8) axes to allow any input to control the joystick(s). 4 directions per joystick
if (key.contains("JOYSTICK"))
break;
// Check dpad/pov
for (int pov = 0; pov < 1000; pov++) {
PovDirection povDirection = controller.getPov(pov);
if (!povDirection.equals(PovDirection.center)) {
input_type = ConfigKeymap.Input.TYPE_POV;
input = pov;
input_extra = povDirection.ordinal();
break main;
}
}
// Check buttons
for (int button = 0; button < 1000; button++) {
if (controller.getButton(button)) {
input_type = ConfigKeymap.Input.TYPE_BUTTON;
input = button;
break main;
}
}
return;
}
if (input < 0)
return;
// Save input
config.putInput(this.key, input_type, input, input_extra);
config.load();
config.flush();
Client.setStage(new StageConfigInput(type, config, key, displayName, controllerName));
}
示例4: bindPovButton
import com.badlogic.gdx.controllers.PovDirection; //导入方法依赖的package包/类
public void bindPovButton(PovDirection pov, String name) {
this.povButtons[pov.ordinal()] = name;
}
示例5: removePovBind
import com.badlogic.gdx.controllers.PovDirection; //导入方法依赖的package包/类
public void removePovBind(PovDirection pov) {
this.povButtons[pov.ordinal()] = null;
}
示例6: isPovDirectionDown
import com.badlogic.gdx.controllers.PovDirection; //导入方法依赖的package包/类
/**
* @param dir
* @return true if the supplied {@link PovDirection} is down
*/
public boolean isPovDirectionDown(PovDirection dir) {
return povDirections[dir.ordinal()];
}