本文整理汇总了Java中com.badlogic.gdx.controllers.mappings.Ouya类的典型用法代码示例。如果您正苦于以下问题:Java Ouya类的具体用法?Java Ouya怎么用?Java Ouya使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Ouya类属于com.badlogic.gdx.controllers.mappings包,在下文中一共展示了Ouya类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createNinjaRabbit
import com.badlogic.gdx.controllers.mappings.Ouya; //导入依赖的package包/类
/**
* Creates a new instance of {@link NinjaRabbit}, defining its graphical, audio and physical
* properties.
*
* @param world
* The Box2D {@link World} onto which to create the {@link Body} and {@link Fixture}
* of the {@link Entity}.
* @param loader
* A {@link BodyEditorLoader} to handle creation of the Entity body and fixtures.
* @param assets
* The {@link AssetManager} from where to extract the graphical and audio resources.
* Those resources should be loaded in the manager before calling this method and
* won't be disposed.
* @param status
* A reference to the global status of the player to be updated from the changes in
* the returned entity inner state.
* @param observers
* An array of event receivers. Events will fire when the active player status
* changes (such as losing lives, collecting items, etc.).
* @return A ready to use instance of a new {@link NinjaRabbit}.
*/
public static Entity createNinjaRabbit(final World world, final BodyEditorLoader loader, final AssetManager assets,
final CurrentPlayerStatus status, final PlayerStatusObserver... observers) {
PhysicsProcessor physics = new NinjaRabbitPhysicsProcessor();
CONTACT_LISTENER.add(physics);
world.setContactListener(CONTACT_LISTENER);
GraphicsProcessor graphics = new NinjaRabbitGraphicsProcessor(assets);
BodyProcessor bodyProcessor = new NinjaRabbitBodyProcessor(world, loader);
AudioProcessor audio = new NinjaRabbitAudioProcessor(assets);
PlayerStatusProcessor player = new NinjaRabbitPlayerStatusProcessor(status);
if (observers != null) {
for (PlayerStatusObserver o : observers) {
player.addObserver(o);
}
}
NinjaRabbit ninjaRabbit = new NinjaRabbit(player, bodyProcessor, graphics, physics, audio);
if (Ouya.isRunningOnOuya()) {
Controllers.clearListeners();
Controllers.addListener(new NinjaRabbitControllerProcessor(ninjaRabbit));
} else {
Gdx.input.setInputProcessor(new NinjaRabbitInputProcessor(ninjaRabbit));
}
return ninjaRabbit;
}
示例2: axisMoved
import com.badlogic.gdx.controllers.mappings.Ouya; //导入依赖的package包/类
@Override
public boolean axisMoved(final Controller controller, final int axisIndex, final float value) {
if (axisIndex == MOVE_AXIS) {
float axisValue = 0.5f * value;
if (Math.abs(axisValue) > Ouya.STICK_DEADZONE) {
if (axisValue > 0) {
character.changeState(NinjaRabbitState.RIGHT);
} else {
character.changeState(NinjaRabbitState.LEFT);
}
} else {
character.changeState(NinjaRabbitState.IDLE);
}
}
return super.axisMoved(controller, axisIndex, value);
}
示例3: map
import com.badlogic.gdx.controllers.mappings.Ouya; //导入依赖的package包/类
@Override
public boolean map(Controller controller, ControllerHelper controllerHelper) {
if (!names.contains(controller.getName(), false)) {
return false;
}
System.out.println("Automapping OUYA controller...");
System.out.println("OUYA controller actually: "+controller.getName());
controllerHelper.map(Input.up, new ControllerButton(controller, getB(Ouya.BUTTON_DPAD_UP)));
controllerHelper.map(Input.down, new ControllerButton(controller, getB(Ouya.BUTTON_DPAD_DOWN)));
controllerHelper.map(Input.left, new ControllerButton(controller, getB(Ouya.BUTTON_DPAD_LEFT)));
controllerHelper.map(Input.right, new ControllerButton(controller, getB(Ouya.BUTTON_DPAD_RIGHT)));
controllerHelper.map(Input.up, new ControllerAxis(controller, getA(Ouya.AXIS_LEFT_Y), true));
controllerHelper.map(Input.down, new ControllerAxis(controller, getA(Ouya.AXIS_LEFT_Y), false));
controllerHelper.map(Input.left, new ControllerAxis(controller, getA(Ouya.AXIS_LEFT_X), true));
controllerHelper.map(Input.right, new ControllerAxis(controller, getA(Ouya.AXIS_LEFT_X), false));
controllerHelper.map(Input.jump, new ControllerButton(controller, getB(Ouya.BUTTON_O)));
controllerHelper.map(Input.pause, new ControllerButton(controller, getB(Ouya.BUTTON_MENU)));
controllerHelper.map(Input.enter, new ControllerButton(controller, getB(Ouya.BUTTON_O)));
controllerHelper.map(Input.androidBack, new ControllerButton(controller, getB(Ouya.BUTTON_A)));
return true;
}
示例4: map
import com.badlogic.gdx.controllers.mappings.Ouya; //导入依赖的package包/类
@Override
public boolean map(Controller controller, ControllerHelper controllerHelper) {
if (Ouya.ID.equals(controller.getName())) {
System.out.println("Automapping OUYA controller...");
controllerHelper.map(Input.up, new ControllerButton(controller, Ouya.BUTTON_DPAD_UP));
controllerHelper.map(Input.down, new ControllerButton(controller, Ouya.BUTTON_DPAD_DOWN));
controllerHelper.map(Input.left, new ControllerButton(controller, Ouya.BUTTON_DPAD_LEFT));
controllerHelper.map(Input.right, new ControllerButton(controller, Ouya.BUTTON_DPAD_RIGHT));
controllerHelper.map(Input.up, new ControllerAxis(controller, Ouya.AXIS_LEFT_Y, true));
controllerHelper.map(Input.down, new ControllerAxis(controller, Ouya.AXIS_LEFT_Y, false));
controllerHelper.map(Input.left, new ControllerAxis(controller, Ouya.AXIS_LEFT_X, true));
controllerHelper.map(Input.right, new ControllerAxis(controller, Ouya.AXIS_LEFT_X, false));
controllerHelper.map(Input.jump, new ControllerButton(controller, Ouya.BUTTON_O));
controllerHelper.map(Input.pause, new ControllerButton(controller, Ouya.BUTTON_MENU));
controllerHelper.map(Input.enter, new ControllerButton(controller, Ouya.BUTTON_O));
controllerHelper.map(Input.androidBack, new ControllerButton(controller, Ouya.BUTTON_A));
return true;
}
return false;
}
示例5: update
import com.badlogic.gdx.controllers.mappings.Ouya; //导入依赖的package包/类
@Override
public void update(float delta) {
simulation.update(delta);
float accelerometerY = Gdx.input.getAccelerometerY();
if (accelerometerY < 0)
simulation.moveShipLeft(delta, Math.abs(accelerometerY) / 10);
else
simulation.moveShipRight(delta, Math.abs(accelerometerY) / 10);
if (invaders.getController() != null) {
if (buttonsPressed > 0) {
simulation.shot();
}
// if the left stick moved, move the ship
float axisValue = invaders.getController()
.getAxis(Ouya.AXIS_LEFT_X) * 0.5f;
if (Math.abs(axisValue) > 0.25f) {
if (axisValue > 0) {
simulation.moveShipRight(delta, axisValue);
} else {
simulation.moveShipLeft(delta, -axisValue);
}
}
}
if (Gdx.input.isKeyPressed(Keys.DPAD_LEFT)
|| Gdx.input.isKeyPressed(Keys.A))
simulation.moveShipLeft(delta, 0.5f);
if (Gdx.input.isKeyPressed(Keys.DPAD_RIGHT)
|| Gdx.input.isKeyPressed(Keys.D))
simulation.moveShipRight(delta, 0.5f);
if (Gdx.input.isTouched() || Gdx.input.isKeyPressed(Keys.SPACE)) {
simulation.shot();
i++;
Log.d("aaa", "shot++++++++++++++++++++++++++++++++++ i = " + i);
}
}
示例6: update
import com.badlogic.gdx.controllers.mappings.Ouya; //导入依赖的package包/类
@Override
public void update (float delta) {
simulation.update(delta);
float accelerometerY = Gdx.input.getAccelerometerY();
if (accelerometerY < 0)
simulation.moveShipLeft(delta, Math.abs(accelerometerY) / 10);
else
simulation.moveShipRight(delta, Math.abs(accelerometerY) / 10);
if (invaders.getController() != null) {
if (buttonsPressed > 0) {
simulation.shot();
}
// if the left stick moved, move the ship
float axisValue = invaders.getController().getAxis(Ouya.AXIS_LEFT_X) * 0.5f;
if (Math.abs(axisValue) > 0.25f) {
if (axisValue > 0) {
simulation.moveShipRight(delta, axisValue);
} else {
simulation.moveShipLeft(delta, -axisValue);
}
}
}
if (Gdx.input.isKeyPressed(Keys.DPAD_LEFT) || Gdx.input.isKeyPressed(Keys.A)) simulation.moveShipLeft(delta, 0.5f);
if (Gdx.input.isKeyPressed(Keys.DPAD_RIGHT) || Gdx.input.isKeyPressed(Keys.D)) simulation.moveShipRight(delta, 0.5f);
if (Gdx.input.isTouched() || Gdx.input.isKeyPressed(Keys.SPACE)) simulation.shot();
}
示例7: handlePlayerInputs
import com.badlogic.gdx.controllers.mappings.Ouya; //导入依赖的package包/类
private void handlePlayerInputs() {
if(controller != null && controller.getName().equals(Ouya.ID)) {
handleOuyaInputs();
} else {
handleKeyboardInputs();
}
}
示例8: getX
import com.badlogic.gdx.controllers.mappings.Ouya; //导入依赖的package包/类
@Override
public float getX() {
if (controller == null) {
return 0f;
}
return controller.getAxis(Ouya.AXIS_RIGHT_X) * SPEED;
}
示例9: getY
import com.badlogic.gdx.controllers.mappings.Ouya; //导入依赖的package包/类
@Override
public float getY() {
if (controller == null) {
return 0f;
}
return controller.getAxis(Ouya.AXIS_RIGHT_Y) * SPEED;
}
示例10: getActionPress
import com.badlogic.gdx.controllers.mappings.Ouya; //导入依赖的package包/类
@Override
public boolean getActionPress() {
if (controller == null) {
return false;
}
return controller.getButton(Ouya.BUTTON_O);
}
示例11: getForward
import com.badlogic.gdx.controllers.mappings.Ouya; //导入依赖的package包/类
@Override
public float getForward() {
if (controller == null) {
return 0f;
}
if (controller.getAxis(Ouya.AXIS_LEFT_Y) == 0f) {
return 0f;
}
return controller.getAxis(Ouya.AXIS_LEFT_Y);
}
示例12: getLeft
import com.badlogic.gdx.controllers.mappings.Ouya; //导入依赖的package包/类
@Override
public float getLeft() {
if (controller == null) {
return 0f;
}
if (controller.getAxis(Ouya.AXIS_LEFT_X) == 0f) {
return 0f;
}
return controller.getAxis(Ouya.AXIS_LEFT_X);
}
示例13: getShift
import com.badlogic.gdx.controllers.mappings.Ouya; //导入依赖的package包/类
@Override
public boolean getShift() {
if (controller == null) {
return false;
}
return controller.getButton(Ouya.BUTTON_A);
}
示例14: init
import com.badlogic.gdx.controllers.mappings.Ouya; //导入依赖的package包/类
@Override
public void init(int id) {
if (controller == null) {
for (int i = 0; i < Controllers.getControllers().size; i++) {
Controller current = Controllers.getControllers().get(i);
// Dispose any irregular controllers
if (current.getName().equals(Ouya.ID)) {
controller = Controllers.getControllers().get(i);
break;
}
}
}
}
示例15: initializePlayers
import com.badlogic.gdx.controllers.mappings.Ouya; //导入依赖的package包/类
private void initializePlayers() {
Player player = new Player();
player.setColor(PlayerColor.BLUE);
Array<Controller> controllers = Controllers.getControllers();
if (Ouya.runningOnOuya) {
ControllerInputHandler inputHandler = new ControllerInputHandler();
inputHandler.setController(controllers.get(0));
inputHandler.setMapping(InputMapping.OUYAMapping());
player.setInputHandler(inputHandler);
} else {
if (Controllers.getControllers().size > 0) {
ControllerInputHandler controllerInputHandler = new ControllerInputHandler();
controllerInputHandler.setController(Controllers
.getControllers().first());
controllerInputHandler
.setMapping(InputMapping.XBOX360Mapping());
player.setInputHandler(controllerInputHandler);
} else {
KeyboardInputHandler keyboardInputHandler = new KeyboardInputHandler();
keyboardInputHandler.setMapping(InputMapping
.KeyboardArrowsMapping());
player.setInputHandler(keyboardInputHandler);
}
}
players.add(player);
}