示例#1
0
文件: Mouse.java 项目: LukaJCB/pg3b
 public float getState() {
   if (button > 0) return instance.isPressed(button) ? 1 : 0;
   if ("x".equals(axis)) return instance.currentDeltaX;
   if ("y".equals(axis)) return instance.currentDeltaY;
   if (mouseWheel) {
     if (mouseWheelTime > 0) {
       if (System.currentTimeMillis() < mouseWheelTime) return lastMoustWheel;
       mouseWheelTime = 0;
     }
     lastMoustWheel = instance.currentMouseWheel;
     if (lastMoustWheel != 0)
       mouseWheelTime = System.currentTimeMillis() + MOUSEWHEEL_CHANGE_TIME;
     return lastMoustWheel;
   }
   return 0;
 }
示例#2
0
 void notifyReceived(Object object) {
   if (object instanceof Ping) {
     Ping ping = (Ping) object;
     if (ping.isReply) {
       if (ping.id == lastPingID - 1) {
         returnTripTime = (int) (System.currentTimeMillis() - lastPingSendTime);
         if (TRACE) trace("kryonet", this + " return trip time: " + returnTripTime);
       }
     } else {
       ping.isReply = true;
       sendTCP(ping);
     }
   }
   Listener[] listeners = this.listeners;
   for (int i = 0, n = listeners.length; i < n; i++) listeners[i].received(this, object);
 }
示例#3
0
 /**
  * Requests the connection to communicate with the remote computer to determine a new value for
  * the {@link #getReturnTripTime() return trip time}. When the connection receives a {@link
  * FrameworkMessage.Ping} object with {@link Ping#isReply isReply} set to true, the new return
  * trip time is available.
  */
 public void updateReturnTripTime() {
   Ping ping = new Ping();
   ping.id = lastPingID++;
   lastPingSendTime = System.currentTimeMillis();
   sendTCP(ping);
 }