コード例 #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
ファイル: Connection.java プロジェクト: 9cat/kryonet
 /** If the listener already exists, it is not added again. */
 public void addListener(Listener listener) {
   if (listener == null) throw new IllegalArgumentException("listener cannot be null.");
   synchronized (listenerLock) {
     Listener[] listeners = this.listeners;
     int n = listeners.length;
     for (int i = 0; i < n; i++) if (listener == listeners[i]) return;
     Listener[] newListeners = new Listener[n + 1];
     newListeners[0] = listener;
     System.arraycopy(listeners, 0, newListeners, 1, n);
     this.listeners = newListeners;
   }
   if (TRACE) trace("kryonet", "Connection listener added: " + listener.getClass().getName());
 }
コード例 #3
0
ファイル: Connection.java プロジェクト: 9cat/kryonet
 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);
 }
コード例 #4
0
ファイル: Connection.java プロジェクト: 9cat/kryonet
 /**
  * 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);
 }