Đang chuẩn bị liên kết để tải về tài liệu:
Foundation Silverlight 3 Animation- P13

Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ

Foundation Silverlight 3 Animation- P13: Silverlight has really come a long way since I started using it. It’s kind of interesting to look back a mere two years (roughly) and think about how the workflow has changed. Of even more interest is the staggering speed at which new features are being added. In the time I’ve been using Silverlight, it has grown from a somewhat limited toolset to an ever-more-impressive technology that has really started to come into its own. | COLLISIONS double DX Canvas.GetLett whichBall - Canvas.GetLett theLine double DY Canvas.GetTop whichBall - Canvas.GetTop theLine double X1 DX Cosine DY Sine double Y1 DY Cosine -DX Sine double VX1 Cosine whichBall.Velocity.X Sine whichBall.Velocity.Y double VY1 Cosine whichBall.Velocity.Y - Sine whichBall.Velocity.X it Y1 - whichBall.Height I 2 Y1 - whichBall.Height I 2 VY1 Restitution double X Cosine X1- Sine Yl double Y Cosine Y1 Sine Xi whichBall.Velocity.X Cosine VX1 - Sine VY1 whichBall.Velocity.Y Cosine VY1 Sine VX1 Canvas.SetLett whichBallj Canvas.GetLett theLine X Canvas.SetTop whichBallj Canvas.GetTop theLine Y Press F5 to compile and run the program again. This time the ball drops hits the line bounces and drops off the line as you would expect it to. However after hitting the edge of the application and rolling back toward the line the ball moves inside the right boundary and then appears to jump as the code calculates the collision again. This issue is easily corrected. 19. Locate the if statement that performs the collision reaction calculation it will look like this it Yl - whichBall.Height I 2 . Change it so that it includes an and function like the code shown following. The Yl VY1 tests the rotated position of the ball to see if it is less than the velocity of the ball. When above the line the ball s rotated y position is negative so it will be less than the ball s y velocity which is positive as the ball drops. Once below the line and inside the line s boundaries the ball s rotated y position becomes positive and is greater than the ball s y velocity so no collision takes place. it Yl - whichBall.Height I 2 Yl VY1 Now when you compile and run the program the ball will roll under the line as expected. Play around with the angle of the line a little bit and see what kind of effect it has on the ball bouncing. Take a few minutes and add a slider to the application that allows you to change the angle of the line while the application is running. If you