tailieunhanh - Foundation Silverlight 3 Animation- P10
Foundation Silverlight 3 Animation- P10: 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. | USING TRIGONOMETRY FOR ANIMATION 7. The MouseMove event handler code is shown in the following listing. The idea here is to only strum a string when the mouse is moved toward the bottom of the application. To do this we start by getting the current position of the mouse. We can then check the current mouse position against the last mouse position to determine which way the mouse is moving and if it has encountered the y position where a string is located. The first check says If the mouse is located at 344y or greater and the last mouse position was less than 344y meaning it was above the string then play that string s Vibrate storyboard. Each of the other five strings is checked the same way with the appropriate y value inserted for the tests. private void Page_MouseMove object sender MouseEventArgs e MousePosition null it 344 344 it 328 328 it 312 312 it 296 296 it 280 280 it 265 265 LastMousePosition MousePosition When the application is run the guitar and strings are drawn in the application as shown in Figure 6-24. When the mouse is positioned above the strings and moved downward the strings will vibrate as they 251 CHAPTER 6 are encountered and continue to oscillate until the range dampening cuts the motion down enough to reset the string for the next pass. Ideally a range of y values would be provided to test for each string hit as it is possible to move the mouse over a string without a hit being registered. In addition a string should not be reset until the vibration has dampened enough to drop below the threshold set in the user control so you cannot continuously strum the strings. Figure 6-24. The .
đang nạp các trang xem trước