本文整理汇总了Java中com.badlogic.gdx.controllers.mappings.Ouya类的典型用法代码示例。如果您正苦于以下问题:Java Ouya类的具体用法?Java Ouya怎么用?Java Ouya使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Ouya类属于com.badlogic.gdx.controllers.mappings包,在下文中一共展示了Ouya类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:nfantone,项目名称:ninja-rabbit,代码行数:46,代码来源:EntityFactory.java
示例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);
}
开发者ID:nfantone,项目名称:ninja-rabbit,代码行数:17,代码来源:NinjaRabbitControllerProcessor.java
示例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;
}
开发者ID:0x0ade,项目名称:shadow-engine,代码行数:25,代码来源:OuyaSystemControllerMapping.java
示例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;
}
开发者ID:0x0ade,项目名称:shadow-engine,代码行数:21,代码来源:ControllerHelper.java
示例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);
}
}
开发者ID:jiangerji,项目名称:android-screen-recorder,代码行数:40,代码来源:GameLoop.java
示例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();
}
开发者ID:konsoletyper,项目名称:teavm-libgdx,代码行数:31,代码来源:GameLoop.java
示例7: handlePlayerInputs
import com.badlogic.gdx.controllers.mappings.Ouya; //导入依赖的package包/类
private void handlePlayerInputs() {
if(controller != null && controller.getName().equals(Ouya.ID)) {
handleOuyaInputs();
} else {
handleKeyboardInputs();
}
}
开发者ID:futurice,项目名称:sanko-game,代码行数:8,代码来源:CloudsGame.java
示例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;
}
开发者ID:neuroradiology,项目名称:TinyVoxel,代码行数:8,代码来源:OuyaController.java
示例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;
}
开发者ID:neuroradiology,项目名称:TinyVoxel,代码行数:8,代码来源:OuyaController.java
示例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);
}
开发者ID:neuroradiology,项目名称:TinyVoxel,代码行数:8,代码来源:OuyaController.java
示例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);
}
开发者ID:neuroradiology,项目名称:TinyVoxel,代码行数:11,代码来源:OuyaController.java
示例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);
}
开发者ID:neuroradiology,项目名称:TinyVoxel,代码行数:11,代码来源:OuyaController.java
示例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);
}
开发者ID:neuroradiology,项目名称:TinyVoxel,代码行数:8,代码来源:OuyaController.java
示例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;
}
}
}
}
开发者ID:neuroradiology,项目名称:TinyVoxel,代码行数:14,代码来源:OuyaController.java
示例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);
}
开发者ID:martinhoeller,项目名称:bbg-gdx-project-setup,代码行数:30,代码来源:GameScreen.java
示例16: OUYAMapping
import com.badlogic.gdx.controllers.mappings.Ouya; //导入依赖的package包/类
public static InputMapping OUYAMapping() {
InputMapping ouyaMapping = new InputMapping();
ouyaMapping.mapControl(Control.DOWN, Ouya.BUTTON_DPAD_DOWN);
ouyaMapping.mapControl(Control.UP, Ouya.BUTTON_DPAD_UP);
ouyaMapping.mapControl(Control.LEFT, Ouya.BUTTON_DPAD_LEFT);
ouyaMapping.mapControl(Control.RIGHT, Ouya.BUTTON_DPAD_RIGHT);
ouyaMapping.mapControl(Control.FIRE, Ouya.BUTTON_O);
ouyaMapping.mapControl(Control.START, Ouya.BUTTON_MENU);
return ouyaMapping;
}
开发者ID:martinhoeller,项目名称:bbg-gdx-project-setup,代码行数:11,代码来源:InputMapping.java
示例17: update
import com.badlogic.gdx.controllers.mappings.Ouya; //导入依赖的package包/类
@Override
public void update (float delta) {
simulation.update(delta);
// float q1 = BLEDeviceScanActivity.latest_Q0;
// float q2 = BLEDeviceScanActivity.latest_Q1;
// float q3 = BLEDeviceScanActivity.latest_Q2;
// float q4 = BLEDeviceScanActivity.latest_Q3;
//
// //Equation from Omid's paper with conversions to make the math work
// double pi_d = Math.PI;
// float pi_f = (float)pi_d;
//
// double q1_double = q1;
// double theta_double = 2*Math.acos(q1_double);
// float theta = (float)theta_double*180/pi_f;
//
// double q2_double = q2;
// double rx_double = -1 * q2_double / Math.sin(theta_double/2);
// float rx = (float)rx_double;
//
// double q3_double = q3;
// double ry_double = -1 * q3_double / Math.sin(theta_double/2);
// float ry = (float)ry_double;
//
// double q4_double = q4;
// double rz_double = -1 * q4_double / Math.sin(theta_double/2);
// float rz = (float)rz_double;
float q0 = (float) Invaders.mInvaderInterface.getQ0();
float q1 = (float) Invaders.mInvaderInterface.getQ1();
float q2 = (float) Invaders.mInvaderInterface.getQ2();
float q3 = (float) Invaders.mInvaderInterface.getQ3();
float accelerometerY = Gdx.input.getAccelerometerY();
// if (accelerometerY < 0)
if (0.2f * (q0 * q1 + q2 * q3)>0) {
// simulation.moveShipLeft(delta, Math.abs(accelerometerY) / 10);
simulation.moveShipLeft(delta, Math.abs(0.2f * (q0 * q1 + q2 * q3)));
}
else
// simulation.moveShipRight(delta, Math.abs(accelerometerY) / 10);
simulation.moveShipRight(delta,Math.abs(0.2f * (q0 * q1 + q2 * q3)));
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();
}
开发者ID:Motsai,项目名称:neblina-libgdx3d,代码行数:64,代码来源:GameLoop.java
示例18: handleOuyaInputs
import com.badlogic.gdx.controllers.mappings.Ouya; //导入依赖的package包/类
private void handleOuyaInputs() {
float leftXAxis = controller.getAxis(Ouya.AXIS_LEFT_X);
boolean oButton = controller.getButton(Ouya.BUTTON_O);
boolean dashLeft = controller.getButton(Ouya.BUTTON_L1) || controller.getButton(Ouya.BUTTON_L2);
boolean dashRight = controller.getButton(Ouya.BUTTON_R1) || controller.getButton(Ouya.BUTTON_R2);
// Execute shoot
if (oButton) {
if (!bulletJustShot) {
bullets.add(new Bullet(hero.x, hero.y));
bulletJustShot = true;
}
} else {
bulletJustShot = false;
}
// Execute dash
if (dashLeft) {
if (!justDashed) {
hero.setVelocityX(-GamePlayParams.HERO_DASH_SPEED_X);
justDashed = true;
}
} else if (dashRight) {
if (!justDashed) {
hero.setVelocityX(GamePlayParams.HERO_DASH_SPEED_X);
justDashed = true;
}
} else {
justDashed = false;
}
// Decelerate dash
if (Math.abs(hero.getVelocityX()) > GamePlayParams.HERO_MOVE_SPEED_X) {
hero.setVelocityX(hero.getVelocityX() * GamePlayParams.HERO_MOVE_DECELERATION_X);
}
// Fix for 'neutral' threshold
if (Math.abs(leftXAxis) < 0.1) {
leftXAxis = 0;
}
// Decelerate
if (leftXAxis == 0 && Math.abs(hero.getVelocityX()) <= GamePlayParams.HERO_MOVE_SPEED_X) {
hero.setVelocityX(hero.getVelocityX() * GamePlayParams.HERO_MOVE_DECELERATION_X);
}
// Move sideways
else if (Math.abs(hero.getVelocityX()) <= GamePlayParams.HERO_MOVE_SPEED_X) {
hero.setVelocityX(leftXAxis*GamePlayParams.HERO_MOVE_SPEED_X);
}
}
开发者ID:futurice,项目名称:sanko-game,代码行数:49,代码来源:CloudsGame.java
示例19: getControllerType
import com.badlogic.gdx.controllers.mappings.Ouya; //导入依赖的package包/类
public static ControllerType getControllerType(Controller controller) {
String controllerName = controller.getName();
String lowercaseControllerName = controllerName.toLowerCase();
if (controller.getName().equals(Ouya.ID)) {
return ControllerType.OUYA;
}
if (lowercaseControllerName.contains(XboxOneController.ID)) {
return ControllerType.XBOX_ONE;
}
if (lowercaseControllerName.contains(Xbox360Controller.ID)) {
return ControllerType.XBOX_360;
}
if (lowercaseControllerName.contains(PS3Controller.ID_FULL)) {
return ControllerType.PS3;
} else if (lowercaseControllerName.contains(PS3Controller.ID_PREFIX)
&& lowercaseControllerName.contains(PS3Controller.ID_SUFFIX)) {
return ControllerType.PS3;
}
switch(Mdx.os) {
case WINDOWS:
if(lowercaseControllerName.equals(PS4Controller.WINDOWS_ID)) {
return ControllerType.PS4;
} else if(lowercaseControllerName.equals(PS4Controller.MAC_ID)) {
return ControllerType.PS4;
}
break;
case MAC:
if(lowercaseControllerName.equals(PS4Controller.MAC_ID)) {
return ControllerType.PS4;
}
break;
case UNIX:
break;
case UNKNOWN:
case ANDROID:
case IOS:
default:
break;
}
Gdx.app.log(LOGGING_TAG, "Could not find controller mappings for " + controller.getName());
return ControllerType.UNKNOWN;
}
开发者ID:mini2Dx,项目名称:mini2Dx,代码行数:45,代码来源:ControllerMapping.java
注:本文中的com.badlogic.gdx.controllers.mappings.Ouya类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论