private void MouseLeftButtonUp()
        {
            if (cursorJoint == null)
            {
                return;
            }

            space.RemoveConstraint(cursorJoint);
            cursorJoint.Dispose();
            cursorJoint = null;

            demo[currentDemo].OnMouseLeftButtonUp(chipmunkDemoMouse);
        }
Exemplo n.º 2
0
        private void RemoveConstraint()
        {
            //Remove and dispose the current constraint
            simulation.RemoveConstraint(currentConstraint);
            currentConstraint.Dispose();

            //Stop motion and reset the rigid bodies
            cubeRigidBody.PhysicsWorldTransform = Matrix.Translation(new Vector3(2, 0, -9)) *
                                                  Matrix.RotationQuaternion(new Quaternion(0, 0, 0, 1));

            cubeRigidBody.AngularVelocity = Vector3.Zero;
            cubeRigidBody.LinearVelocity  = Vector3.Zero;

            sphereRigidBody.PhysicsWorldTransform = Matrix.Translation(new Vector3(-2, 0, -9)) *
                                                    Matrix.RotationQuaternion(new Quaternion(0, 0, 0, 1));

            sphereRigidBody.AngularVelocity = Vector3.Zero;
            sphereRigidBody.LinearVelocity  = Vector3.Zero;
        }
Exemplo n.º 3
0
        protected void SetRootLeftTopPadding(int leftPadding, int topPadding)
        {
            var top  = GetVariableFromViewAndAttribute(rootView, LayoutAttribute.Top);
            var left = GetVariableFromViewAndAttribute(rootView, LayoutAttribute.Left);

            if (rootTopConstraint != null)
            {
                solver.removeConstraint(rootTopConstraint);
                rootTopConstraint.Dispose();
            }
            if (rootLeftConstraint != null)
            {
                solver.removeConstraint(rootLeftConstraint);
                rootLeftConstraint.Dispose();
            }

            //for the root view, left and right position are equal zero
            //top == 0
            rootTopConstraint = new Constraint(kiwi.kiwi.__minus__(top, new Expression(topPadding)), RelationalOperator.OP_EQ, kiwi.kiwi.required);
            solver.addConstraint(rootTopConstraint);
            //left == 0
            rootLeftConstraint = new Constraint(kiwi.kiwi.__minus__(left, new Expression(leftPadding)), RelationalOperator.OP_EQ, kiwi.kiwi.required);
            solver.addConstraint(rootLeftConstraint);
        }