Exemple #1
0
 public static void RouteTouchUp(CCNode root, Touch touch)
 {
     CCPoint touchLocation = touch.CCTouch.Location;
     if (root.ChildrenCount > 0)
     {
         for (int i = root.ChildrenCount - 1; i >= 0; i--)
         {
             RouteTouchUp(root.Children[i], touch);  //递归
             if (touch.Handled == true) return;
             ITouch itouch = root.Children[i] as ITouch;
             if (itouch != null)
             {
                 CCNode node = root.Children[i] as CCNode;
                 if (node.Parent.Visible == true && node.Visible == true)
                 {
                     CCPoint local = node.ConvertToNodeSpace(touchLocation);
                     CCRect r = new CCRect(
                         node.PositionX - node.ContentSize.Width * node.AnchorPoint.X,
                         node.PositionY - node.ContentSize.Height * node.AnchorPoint.Y,
                         node.ContentSize.Width,
                         node.ContentSize.Height
                         );
                     r.Origin = CCPoint.Zero;
                     if (r.ContainsPoint(local))
                         itouch.OnTouchDown(touch);
                 }
             }
         }
     }
 }
Exemple #2
0
 public void OnTouchMove(Touch e)
 {
     if (this.TouchMove != null)
         this.TouchMove(this, e);
 }
Exemple #3
0
 public void OnTouchUp(Touch e)
 {
     if (this.TouchUp != null)
         this.TouchUp(this, e);
 }
Exemple #4
0
 public void OnTouchDown(Touch e)
 {
     if (this.TouchDown != null)
         this.TouchDown(this, e);
 }