Ejemplo n.º 1
0
 public void AddJoint(CCPhysicsJointInfo joint)
 {
     foreach (cpConstraint subjoint in joint.getJoints())
     {
         _space.AddConstraint(subjoint);
     }
 }
Ejemplo n.º 2
0
        public virtual void OnTouchesBegan(List <CCTouch> touches, CCEvent e)
        {
            var touch = touches.FirstOrDefault();


            CCMouse.Instance.UpdatePositionLocation(touch.LocationOnScreen, this); //Update mouse mouse position

            CCMouse.Instance.UpdateBodyPosition();

            CCMouse.Instance.OnTouchBegan(touch, this);

            if (!CCMouse.Instance.HasBodyJoined)
            {
                float radius = 5.0f;

                cpPointQueryInfo info = null;
                var shape             = space.PointQueryNearest(
                    CCMouse.Instance.Position, radius, GRAB_FILTER, ref info);
                if (shape != null)
                {
                    cpVect nearest = (info.distance > 0.0d ? info.point : CCMouse.Instance.Position);

                    CCMouse.Instance.mouseJoint = new cpPivotJoint(CCMouse.Instance.mouseBody, shape.body, cpVect.Zero, shape.body.WorldToLocal(nearest));
                    CCMouse.Instance.mouseJoint.SetMaxForce(50000);
                    CCMouse.Instance.mouseJoint.SetErrorBias(cp.cpfpow(1f - 0.15f, 60f));
                    space.AddConstraint(CCMouse.Instance.mouseJoint);
                    return;
                }
            }

            //Arrastramos el logo
            if (logo.BoundingBox.ContainsPoint(CCMouse.Instance.PositionParentSpace))
            {
                logo.MoveOffset = touch.LocationOnScreen - logo.Position;
                CCMouse.Instance.IsDragBlocked = logo.IsMoving = true;
                return;
            }
        }