xiaojiangren 2016-01-31 07:06 采纳率: 27%
浏览 1401
已采纳

求大神看下代码 这是什么意思啊

@Override
public boolean onSDKGenericMotionEvent(MotionEvent ev) {
updateConnected(ev.getDeviceId());
float ltrigger = ev.getAxisValue(MotionEvent.AXIS_LTRIGGER);
float rtrigger = ev.getAxisValue(MotionEvent.AXIS_RTRIGGER);
btnL2.setTriggerValue(ltrigger);
btnR2.setTriggerValue(rtrigger);
float x = ev.getAxisValue(MotionEvent.AXIS_X);
float y = ev.getAxisValue(MotionEvent.AXIS_Y);
float hatx = ev.getAxisValue(MotionEvent.AXIS_HAT_X);
float haty = ev.getAxisValue(MotionEvent.AXIS_HAT_Y);
float z = ev.getAxisValue(MotionEvent.AXIS_Z);
float rz = ev.getAxisValue(MotionEvent.AXIS_RZ);
joystick1.setPos(x, y);
joystick2.setPos(z, rz);
btnLeft.setTriggerValue(0);
btnRight.setTriggerValue(0);
btnUp.setTriggerValue(0);
btnDown.setTriggerValue(0);
if (hatx < 0) {
btnLeft.setTriggerValue(hatx);
} else {
btnRight.setTriggerValue(hatx);
}
if (haty < 0) {
btnUp.setTriggerValue(haty);
} else {
btnDown.setTriggerValue(haty);
}
return true;
}

joystick1 joystick2 这个是两个类似于街机的摇动方向的那个button 这代码是什么意思啊大概

  • 写回答

1条回答

  • threenewbee 2016-01-31 07:11
    关注

    这个是sdk里面的运动感应传感器

    详细的参数:
    http://cs.szpt.edu.cn/android/reference/android/view/MotionEvent.html

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥17 pro*C预编译“闪回查询”报错SCN不能识别
  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向