예제 #1
0
 /// <summary>
 /// Invoke from OnDestroy() method in your per level game object.
 /// Uses the hash code to identify the listener over the list of many listeners.
 /// </summary>
 public void removeListener(ITouchListener listener)
 {
     if (!listener.isStatic())
     {
         dynamicListeners.remove(listener);
     }
     else
     {
         // need to remove from every list the listener appears
         ListenerLists[] lls = staticQuadTree.traverse(listener.getScreenBoundsAA());
         for (int i = 0, c = lls.Length; i < c; ++i)
         {
             // first listenerList element being not valid means next ones are also invalid
             if (lls[i] == null)
             {
                 break;
             }
             lls[i].remove(listener);
         }
     }
 }
예제 #2
0
 /// <summary>
 /// Register the specified iListener in the adequate list to be processed on every touch event.
 /// </summary>
 /// <param name='listener'>
 /// The object you are registering. Needed for callback invocations.
 /// </param>
 /// <param name='touchPhases'>
 /// All the touch phases you want your gameobject be registered to.
 /// </param>
 public void register(ITouchListener listener, params TouchPhase[] touchPhases)
 {
     if (!listener.isStatic())
     {
         dynamicListeners.add(listener, touchPhases);
     }
     else
     {
         /// adding the listener's screen rect into the quad tree will return a list of
         /// as much as 4 ListenerLists elems, since the listener can fall in more than one quadrant
         ListenerLists[] leaves = staticQuadTree.add(listener.getScreenBoundsAA());
         for (int i = 0, c = leaves.Length; i < c; ++i)
         {
             // first listenerList element being not valid means next ones are also invalid
             if (leaves[i] == null)
             {
                 break;
             }
             leaves[i].add(listener, touchPhases);
         }
     }
 }