本文整理汇总了Java中net.java.games.input.Component.isAnalog方法的典型用法代码示例。如果您正苦于以下问题:Java Component.isAnalog方法的具体用法?Java Component.isAnalog怎么用?Java Component.isAnalog使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.java.games.input.Component
的用法示例。
在下文中一共展示了Component.isAnalog方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import net.java.games.input.Component; //导入方法依赖的package包/类
@Override
public void run() {
EventDispatcher.getInstance().addListener(CloseEvent.class, this);
if (FIRST_GAMEPAD == null) {
// Couldn't find a gamepad
LOG.warning("No gamepad found. The GamepadMonitor is not going to run.");
this.running = false;
} else {
this.running = true;
}
while (this.running) {
FIRST_GAMEPAD.poll();
EventQueue queue = FIRST_GAMEPAD.getEventQueue();
// Create an event object to pass down to get populated with the information.
Event event = new Event();
while (queue.getNextEvent(event)) {
Component comp = event.getComponent();
if (!comp.isAnalog() || Math.abs(event.getValue()) > ANALOG_DEAD_ZONE) {
EventDispatcher.getInstance().fire(
new GamepadEvent(comp.getName(),
comp.isAnalog(),
event.getValue())
);
}
}
try {
Thread.sleep(30);
} catch (InterruptedException e) {
LOG.severe(e.getMessage());
}
}
EventDispatcher.getInstance().removeListener(CloseEvent.class, this);
}
示例2: isButton
import net.java.games.input.Component; //导入方法依赖的package包/类
/**
* Return true if the component is a digital/absolute button, and its
* identifier name ends with "Button" (i.e. the identifier class is
* Component.Identifier.Button).
*/
private boolean isButton(Component c) {
if (!c.isAnalog() && !c.isRelative()) { // digital and absolute
String className = c.getIdentifier().getClass().getName();
// log.info(c.getName() + " identifier: " + className);
if (className.endsWith("Button"))
return true;
}
return false;
}
示例3: isPressed
import net.java.games.input.Component; //导入方法依赖的package包/类
private boolean isPressed(Event event) {
Component component = event.getComponent();
if (component.isAnalog()) {
if (Math.abs(event.getValue()) > 0.2f) {
return true;
} else {
return false;
}
} else if (event.getValue() == 0) {
return false;
} else {
return true;
}
}
示例4: setAzione
import net.java.games.input.Component; //导入方法依赖的package包/类
public void setAzione(Component comp, ButtonMap map, float value, String controllerSelected) {
if (controllerSelected.equals(map.getContoller())) {
if (comp.isAnalog()) {
if (comp.getName().equals(map.getForward())) {
speed = (int) (Math.abs(value) * 255);
}
if (comp.getName().equals(map.getLeft())) {
int difference = 0;
int valuex30 = (int) (value * 30);
if (Math.abs(valuex30) > 8) {
difference += 10;
if (Math.abs(valuex30) > 18) {
difference += 10;
if (Math.abs(valuex30) == 30.0) {
difference += 10;
}
}
}
difference = difference * (int) Math.signum(value);
angle = 90 + difference;
}
}
//non è analogico
else{
if (comp.getName().equals(map.getForward())) {
if (value == 0.0f) {
speed = 0;
} else {
speed = 255;
}
}
if (comp.getName().equals(map.getLeft())) {
if (value == 0.0f) {
angle = 90;
} else {
angle = 60;
}
}
if (comp.getName().equals(map.getRight())) {
if (value == 0.0f) {
angle = 90;
} else {
angle = 120;
}
}
}
String strSpeed="";
String strAngle="";
strAngle=String.format("%03d", angle);
strSpeed=String.format("%03d", speed);
changedState(strSpeed + "_" + strAngle);
}
}