当前位置: 首页>>代码示例>>Java>>正文


Java Component.isAnalog方法代码示例

本文整理汇总了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);
}
 
开发者ID:GamesRythmAnalysis,项目名称:RNGames,代码行数:38,代码来源:GamepadMonitor.java

示例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;
}
 
开发者ID:glaudiston,项目名称:project-bianca,代码行数:15,代码来源:Joystick.java

示例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;
    }
}
 
开发者ID:kostkol87,项目名称:Nes-emulator,代码行数:15,代码来源:ControllerImpl.java

示例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);
    }
}
 
开发者ID:carlo-manasse,项目名称:AI-project,代码行数:60,代码来源:JoystickFrame.java


注:本文中的net.java.games.input.Component.isAnalog方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。