本文整理汇总了Java中com.badlogic.gdx.controllers.PovDirection.center方法的典型用法代码示例。如果您正苦于以下问题:Java PovDirection.center方法的具体用法?Java PovDirection.center怎么用?Java PovDirection.center使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.controllers.PovDirection
的用法示例。
在下文中一共展示了PovDirection.center方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPov
import com.badlogic.gdx.controllers.PovDirection; //导入方法依赖的package包/类
public PovDirection getPov (int povIndex) {
OisPov pov = joystick.getPov(povIndex);
switch (pov) {
case Centered:
return PovDirection.center;
case East:
return PovDirection.east;
case North:
return PovDirection.north;
case NorthEast:
return PovDirection.northEast;
case NorthWest:
return PovDirection.northWest;
case South:
return PovDirection.south;
case SouthEast:
return PovDirection.southEast;
case SouthWest:
return PovDirection.southWest;
case West:
return PovDirection.west;
}
return null; // Impossible.
}
示例2: testForBindingController
import com.badlogic.gdx.controllers.PovDirection; //导入方法依赖的package包/类
private Controller testForBindingController() {
for (Controller c : Controllers.getControllers()) {
for (int i = 0; i < 10; i++) {
if (c.getButton(i)) {
return c;
}
}
for (int i = 0; i < 4; i++) {
if (Math.abs(c.getAxis(i)) > 0.75f) {
return c;
}
}
if (c.getPov(0) != PovDirection.center)
return c;
}
return null;
}
示例3: getPov
import com.badlogic.gdx.controllers.PovDirection; //导入方法依赖的package包/类
public PovDirection getPov (int povIndex) {
OisJoystick.OisPov pov = joystick.getPov(povIndex);
switch (pov) {
case Centered:
return PovDirection.center;
case East:
return PovDirection.east;
case North:
return PovDirection.north;
case NorthEast:
return PovDirection.northEast;
case NorthWest:
return PovDirection.northWest;
case South:
return PovDirection.south;
case SouthEast:
return PovDirection.southEast;
case SouthWest:
return PovDirection.southWest;
case West:
return PovDirection.west;
}
return null; // Impossible.
}
示例4: povMoved
import com.badlogic.gdx.controllers.PovDirection; //导入方法依赖的package包/类
public boolean povMoved(Controller arg0, int arg1, PovDirection arg2)
{
//Gdx.app.log("CONTROLLER POV", ""+arg1);
//Gdx.app.log("CONTROLLER POV", ""+arg2);
if (arg2 == PovDirection.center)
{
for (int i = 0; i < mapA.size; i++)
{
if (mapA.get(i).controller.equals(arg0))
{
controlList[i].getCurrent().releasePov();
}
}
}
else
{
for (int i = 0; i < mapA.size; i++)
{
if (mapA.get(i).controller.equals(arg0))
{
controlList[i].getCurrent().pressPov(arg2);
}
}
}
return false;
}
示例5: povMoved
import com.badlogic.gdx.controllers.PovDirection; //导入方法依赖的package包/类
@Override
public boolean povMoved(final Controller controller, final int povIndex, final PovDirection direction) {
if (isAssignedTo(controller)) {
if (direction != null) {
if (direction == PovDirection.center) {
stop();
} else {
movement.x = getX(direction);
movement.y = getY(direction);
}
}
return true;
}
return false;
}
示例6: testForPov
import com.badlogic.gdx.controllers.PovDirection; //导入方法依赖的package包/类
private int testForPov(Controller c) {
if (c == null) {
System.out.println("NULL CONTROLLER");
return -1;
}
if (c.getPov(0) != PovDirection.center)
return 1;
// DebugOutput.info(this, c.getPov(0)+ " ");
return -1;
}
示例7: testAxisToAxisMapping
import com.badlogic.gdx.controllers.PovDirection; //导入方法依赖的package包/类
@Test
public void testAxisToAxisMapping() {
ControllerMappings mappings = new ControllerMappings();
// We test 3 axis
ConfiguredInput axis1 = new ConfiguredInput(ConfiguredInput.Type.axis, 5);
ConfiguredInput axis2 = new ConfiguredInput(ConfiguredInput.Type.axisAnalog, 6);
ConfiguredInput axis3 = new ConfiguredInput(ConfiguredInput.Type.axisDigital, 7);
mappings.addConfiguredInput(axis1);
mappings.addConfiguredInput(axis2);
mappings.addConfiguredInput(axis3);
// ok, configuration done...
mappings.commitConfig();
// now we connect a Controller... and map
MockedController controller = new MockedController();
controller.axisValues = new float[3];
controller.povDirection = PovDirection.center;
controller.axisValues[0] = .2f;
controller.axisValues[1] = .6f;
controller.axisValues[2] = -.2f;
assertEquals(ControllerMappings.RecordResult.recorded, mappings.recordMapping(controller, 5));
//next call too fast
assertEquals(ControllerMappings.RecordResult.not_added, mappings.recordMapping(controller, 6));
controller.axisValues[0] = .2f;
controller.axisValues[1] = .1f;
controller.axisValues[2] = 0;
assertEquals(ControllerMappings.RecordResult.nothing_done, mappings.recordMapping(controller, 6));
controller.axisValues[0] = .6f;
controller.axisValues[1] = .5f;
controller.axisValues[2] = 0;
assertEquals(ControllerMappings.RecordResult.recorded, mappings.recordMapping(controller, 6));
controller.axisValues[0] = .6f;
controller.axisValues[1] = .5f;
controller.axisValues[2] = -1;
assertEquals(ControllerMappings.RecordResult.recorded, mappings.recordMapping(controller, 7));
assertTrue(mappings.getControllerMapping(controller).checkCompleted());
System.out.println(mappings.toJson().toJson(JsonWriter.OutputType.json));
// now check
TestControllerAdapter controllerAdapter = new TestControllerAdapter(mappings);
// the digital
assertTrue(controllerAdapter.axisMoved(controller, 2, .8f));
assertEquals(7, controllerAdapter.lastEventId);
assertTrue(controllerAdapter.axisMoved(controller, 2, -.8f));
assertEquals(7, controllerAdapter.lastEventId);
assertTrue(controllerAdapter.axisMoved(controller, 2, -.2f));
assertEquals(7, controllerAdapter.lastEventId);
assertTrue(controllerAdapter.axisMoved(controller, 1, .8f));
assertEquals(5, controllerAdapter.lastEventId);
assertTrue(controllerAdapter.axisMoved(controller, 0, -.9f));
assertEquals(6, controllerAdapter.lastEventId);
MappedController mappedController = new MappedController(controller, mappings);
controller.axisValues[0] = .6f;
controller.axisValues[1] = .5f;
controller.axisValues[2] = -.7f;
assertEquals(.6f, mappedController.getConfiguredAxisValue(6), .01f);
assertEquals(.5f, mappedController.getConfiguredAxisValue(5), .01f);
assertEquals(-1f, mappedController.getConfiguredAxisValue(7), .01f);
assertEquals(0, mappedController.getConfiguredAxisValue(3), .01f);
}
示例8: testPovToAxisMapping
import com.badlogic.gdx.controllers.PovDirection; //导入方法依赖的package包/类
@Test
public void testPovToAxisMapping() {
ControllerMappings mappings = new ControllerMappings();
// We test 3 axis
ConfiguredInput axis1 = new ConfiguredInput(ConfiguredInput.Type.axis, 5);
ConfiguredInput axis2 = new ConfiguredInput(ConfiguredInput.Type.axisAnalog, 6);
ConfiguredInput axis3 = new ConfiguredInput(ConfiguredInput.Type.axisDigital, 7);
mappings.addConfiguredInput(axis1);
mappings.addConfiguredInput(axis2);
mappings.addConfiguredInput(axis3);
// ok, configuration done...
mappings.commitConfig();
// now we connect a Controller... and map
MockedController controller = new MockedController();
controller.axisValues = new float[3];
controller.povDirection = PovDirection.east;
assertEquals(ControllerMappings.RecordResult.recorded, mappings.recordMapping(controller, 5));
//next call too fast
assertEquals(ControllerMappings.RecordResult.not_added, mappings.recordMapping(controller, 7));
//not two directions
controller.povDirection = PovDirection.northWest;
assertEquals(ControllerMappings.RecordResult.not_added, mappings.recordMapping(controller, 7));
//not same direction on different configurations
controller.povDirection = PovDirection.west;
assertEquals(ControllerMappings.RecordResult.not_added, mappings.recordMapping(controller, 7));
//not for analog axis
controller.povDirection = PovDirection.north;
assertEquals(ControllerMappings.RecordResult.nothing_done, mappings.recordMapping(controller, 6));
assertEquals(ControllerMappings.RecordResult.recorded, mappings.recordMapping(controller, 7));
assertFalse(mappings.getControllerMapping(controller).checkCompleted());
System.out.println(mappings.toJson().toJson(JsonWriter.OutputType.json));
// now check
TestControllerAdapter controllerAdapter = new TestControllerAdapter(mappings);
assertFalse(controllerAdapter.povMoved(controller, 1, PovDirection.center));
// the digital
assertTrue(controllerAdapter.povMoved(controller, 0, PovDirection.center));
assertTrue(controllerAdapter.lastEventId == 5 || controllerAdapter.lastEventId == 7);
assertTrue(controllerAdapter.povMoved(controller, 0, PovDirection.east));
assertTrue(controllerAdapter.lastEventId == 5 || controllerAdapter.lastEventId == 7);
assertTrue(controllerAdapter.povMoved(controller, 0, PovDirection.southEast));
assertTrue(controllerAdapter.lastEventId == 5 || controllerAdapter.lastEventId == 7);
assertTrue(controllerAdapter.povMoved(controller, 0, PovDirection.west));
assertTrue(controllerAdapter.lastEventId == 5 || controllerAdapter.lastEventId == 7);
MappedController mappedController = new MappedController(controller, mappings);
controller.povDirection = PovDirection.center;
assertEquals(0, mappedController.getConfiguredAxisValue(5), .01f);
assertEquals(0, mappedController.getConfiguredAxisValue(6), .01f);
assertEquals(0, mappedController.getConfiguredAxisValue(7), .01f);
controller.povDirection = PovDirection.north;
assertEquals(0, mappedController.getConfiguredAxisValue(5), .01f);
assertEquals(0, mappedController.getConfiguredAxisValue(6), .01f);
assertEquals(-1, mappedController.getConfiguredAxisValue(7), .01f);
controller.povDirection = PovDirection.east;
assertEquals(1, mappedController.getConfiguredAxisValue(5), .01f);
assertEquals(0, mappedController.getConfiguredAxisValue(6), .01f);
assertEquals(0, mappedController.getConfiguredAxisValue(7), .01f);
controller.povDirection = PovDirection.southWest;
assertEquals(-1, mappedController.getConfiguredAxisValue(5), .01f);
assertEquals(0, mappedController.getConfiguredAxisValue(6), .01f);
assertEquals(1, mappedController.getConfiguredAxisValue(7), .01f);
}
示例9: testJsonSaveLoad
import com.badlogic.gdx.controllers.PovDirection; //导入方法依赖的package包/类
@Test
public void testJsonSaveLoad() {
ControllerMappings mappings = new ControllerMappings();
mappings.addConfiguredInput(new ConfiguredInput(ConfiguredInput.Type.button, 1));
mappings.addConfiguredInput(new ConfiguredInput(ConfiguredInput.Type.axis, 2));
mappings.addConfiguredInput(new ConfiguredInput(ConfiguredInput.Type.axis, 3));
mappings.addConfiguredInput(new ConfiguredInput(ConfiguredInput.Type.axis, 4));
mappings.commitConfig();
// now we connect a Controller... and map
MockedController controller = new MockedController();
controller.axisValues = new float[3];
controller.povDirection = PovDirection.center;
controller.axisValues[0] = 1f;
controller.pressedButton = -1;
assertEquals(ControllerMappings.RecordResult.recorded, mappings.recordMapping(controller, 2));
controller.pressedButton = 2;
assertEquals(ControllerMappings.RecordResult.recorded, mappings.recordMapping(controller, 1));
controller.pressedButton = 1;
assertEquals(ControllerMappings.RecordResult.need_second_button, mappings.recordMapping(controller, 3));
controller.pressedButton = 0;
assertEquals(ControllerMappings.RecordResult.recorded, mappings.recordMapping(controller, 3));
controller.pressedButton = -1;
controller.povDirection = PovDirection.east;
assertEquals(ControllerMappings.RecordResult.recorded, mappings.recordMapping(controller, 4));
JsonValue json = mappings.toJson();
System.out.println(json.toJson(JsonWriter.OutputType.json));
MappedController mappedController = new MappedController(controller, mappings);
mappings.resetMappings(controller);
mappedController.refreshMappingCache();
assertEquals(0, mappedController.getConfiguredAxisValue(4), 0.1f);
mappings.fillFromJson(json);
mappedController.refreshMappingCache();
assertEquals(1, mappedController.getConfiguredAxisValue(4), 0.1f);
controller.pressedButton = 2;
assertTrue(mappedController.isButtonPressed(1));
controller.pressedButton = 1;
assertEquals(1, mappedController.getConfiguredAxisValue(3), 0.1f);
}
示例10: getPov
import com.badlogic.gdx.controllers.PovDirection; //导入方法依赖的package包/类
@Override
public PovDirection getPov(int povCode) {
return (povCode != 0 ? PovDirection.center : povDirection);
}
示例11: getPov
import com.badlogic.gdx.controllers.PovDirection; //导入方法依赖的package包/类
@Override
public PovDirection getPov(int povCode) {
return PovDirection.center;
}
示例12: getPov
import com.badlogic.gdx.controllers.PovDirection; //导入方法依赖的package包/类
@Override
public PovDirection getPov (int povIndex) {
return PovDirection.center;
}
示例13: getPov
import com.badlogic.gdx.controllers.PovDirection; //导入方法依赖的package包/类
@Override
public PovDirection getPov(int povCode) {
return PovDirection.center;
}