本文整理汇总了Java中net.java.games.input.Component.getDeadZone方法的典型用法代码示例。如果您正苦于以下问题:Java Component.getDeadZone方法的具体用法?Java Component.getDeadZone怎么用?Java Component.getDeadZone使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.java.games.input.Component
的用法示例。
在下文中一共展示了Component.getDeadZone方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: poll
import net.java.games.input.Component; //导入方法依赖的package包/类
public void poll() {
target.poll();
Event event = new Event();
EventQueue queue = target.getEventQueue();
while (queue.getNextEvent(event)) {
// handle button event
if (buttons.contains(event.getComponent())) {
Component button = event.getComponent();
int buttonIndex = buttons.indexOf(button);
buttonState[buttonIndex] = event.getValue() != 0;
// fire button pressed event
Controllers.addEvent(new ControllerEvent(this,event.getNanos(),ControllerEvent.BUTTON,buttonIndex,false,false));
}
// handle pov events
if (pov.contains(event.getComponent())) {
Component povComponent = event.getComponent();
int povIndex = pov.indexOf(povComponent);
float prevX = getPovX();
float prevY = getPovY();
povValues[povIndex] = event.getValue();
if (prevX != getPovX()) {
Controllers.addEvent(new ControllerEvent(this,event.getNanos(),ControllerEvent.POVX,0,false,false));
}
if (prevY != getPovY()) {
Controllers.addEvent(new ControllerEvent(this,event.getNanos(),ControllerEvent.POVY,0,false,false));
}
}
// handle axis updates
if (axes.contains(event.getComponent())) {
Component axis = event.getComponent();
int axisIndex = axes.indexOf(axis);
float value = axis.getPollData();
// fixed dead zone since most axis don't report it :(
if (Math.abs(value) < deadZones[axisIndex]) {
value = 0;
}
if (Math.abs(value) < axis.getDeadZone()) {
value = 0;
}
if (Math.abs(value) > axesMax[axisIndex]) {
axesMax[axisIndex] = Math.abs(value);
}
// normalize the value based on maximum value read in the past
value /= axesMax[axisIndex];
// fire event
Controllers.addEvent(new ControllerEvent(this,event.getNanos(),ControllerEvent.AXIS,axisIndex,
axisIndex == xaxis,axisIndex == yaxis));
axesValue[axisIndex] = value;
}
}
}
示例2: poll
import net.java.games.input.Component; //导入方法依赖的package包/类
public void poll() {
target.poll();
Event event = new Event();
EventQueue queue = target.getEventQueue();
while (queue.getNextEvent(event)) {
// handle button event
if (buttons.contains(event.getComponent())) {
Component button = event.getComponent();
int buttonIndex = buttons.indexOf(button);
buttonState[buttonIndex] = event.getValue() != 0;
// fire button pressed event
Controllers.addEvent(new ControllerEvent(this,event.getNanos(),ControllerEvent.BUTTON,buttonIndex,
buttonState[buttonIndex],false,false,0,0));
}
// handle pov events
if (pov.contains(event.getComponent())) {
Component povComponent = event.getComponent();
int povIndex = pov.indexOf(povComponent);
float prevX = getPovX();
float prevY = getPovY();
povValues[povIndex] = event.getValue();
if (prevX != getPovX()) {
Controllers.addEvent(new ControllerEvent(this,event.getNanos(),ControllerEvent.POVX,0,false,false));
}
if (prevY != getPovY()) {
Controllers.addEvent(new ControllerEvent(this,event.getNanos(),ControllerEvent.POVY,0,false,false));
}
}
// handle axis updates
if (axes.contains(event.getComponent())) {
Component axis = event.getComponent();
int axisIndex = axes.indexOf(axis);
float value = axis.getPollData();
float xaxisValue = 0;
float yaxisValue = 0;
// fixed dead zone since most axis don't report it :(
if (Math.abs(value) < deadZones[axisIndex]) {
value = 0;
}
if (Math.abs(value) < axis.getDeadZone()) {
value = 0;
}
if (Math.abs(value) > axesMax[axisIndex]) {
axesMax[axisIndex] = Math.abs(value);
}
// normalize the value based on maximum value read in the past
value /= axesMax[axisIndex];
if (axisIndex == xaxis) {
xaxisValue = value;
}
if (axisIndex == yaxis) {
yaxisValue = value;
}
// fire event
Controllers.addEvent(new ControllerEvent(this,event.getNanos(),ControllerEvent.AXIS,axisIndex,false,
axisIndex == xaxis,axisIndex == yaxis,xaxisValue,yaxisValue));
axesValue[axisIndex] = value;
}
}
}
示例3: poll
import net.java.games.input.Component; //导入方法依赖的package包/类
public void poll() {
target.poll();
Event event = new Event();
EventQueue queue = target.getEventQueue();
while (queue.getNextEvent(event)) {
// handle button event
if (buttons.contains(event.getComponent())) {
Component button = event.getComponent();
int buttonIndex = buttons.indexOf(button);
buttonState[buttonIndex] = event.getValue() != 0;
// fire button pressed event
Controllers.addEvent(new ControllerEvent(this, event.getNanos(), ControllerEvent.BUTTON, buttonIndex,
buttonState[buttonIndex], false, false, 0, 0));
}
// handle pov events
if (pov.contains(event.getComponent())) {
Component povComponent = event.getComponent();
int povIndex = pov.indexOf(povComponent);
float prevX = getPovX();
float prevY = getPovY();
povValues[povIndex] = event.getValue();
if (prevX != getPovX()) {
Controllers.addEvent(new ControllerEvent(this, event.getNanos(), ControllerEvent.POVX, 0, false, false));
}
if (prevY != getPovY()) {
Controllers.addEvent(new ControllerEvent(this, event.getNanos(), ControllerEvent.POVY, 0, false, false));
}
}
// handle axis updates
if (axes.contains(event.getComponent())) {
Component axis = event.getComponent();
int axisIndex = axes.indexOf(axis);
float value = axis.getPollData();
float xaxisValue = 0;
float yaxisValue = 0;
// fixed dead zone since most axis don't report it :(
if (Math.abs(value) < deadZones[axisIndex]) {
value = 0;
}
if (Math.abs(value) < axis.getDeadZone()) {
value = 0;
}
if (Math.abs(value) > axesMax[axisIndex]) {
axesMax[axisIndex] = Math.abs(value);
}
// normalize the value based on maximum value read in the past
value /= axesMax[axisIndex];
if (axisIndex == xaxis) {
xaxisValue = value;
}
if (axisIndex == yaxis) {
yaxisValue = value;
}
// fire event
Controllers.addEvent(new ControllerEvent(this, event.getNanos(), ControllerEvent.AXIS, axisIndex, false,
axisIndex == xaxis, axisIndex == yaxis, xaxisValue, yaxisValue));
axesValue[axisIndex] = value;
}
}
}