TAILIEUCHUNG - Foundation Silverlight 3 Animation- P7

Foundation Silverlight 3 Animation- P7: 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. | COORDINATES IN SILVERLIGHT 12. After the closing curly brace of the MainPage constructor create the event handler function private void Page_KeyDown object sender KeyEventArgs e 13. Inside the function add the following switch statement. This statement handles the up down left or right arrow keys and then updates the particle s velocity and the on-screen text appropriately. switch case - 1 break case 1 break case - 1 break case 1 break Press F5 to compile and run the program. As you press the arrow keys the velocity of the particle will change as will the motion of the particle on the canvas. The final code for this example can be found in the twoDimensionalVectorCompleted project. As you can see from this application vectors are relatively easily manipulated as an application is running and will affect the movement of the object to which they are applied in real time. Changing the direction of a vector When manipulating objects moving along vectors programmatically you can change their direction by multiplying one or both components by -1. For example given a positive vector of 3 the vector is effectively reversed when multiplied by -1. This will reverse the vector as 3 X -1 -3. The multiplication of two negative numbers results in a positive so a negative vector multiplied by -1 will become positive. For example -3 X -1 3. This is a very useful way to reverse an object s direction completely or just along a single axis if necessary. Take a look at Figure 5-6 which shows the vector 5 5. In the image you can also see what the effect would be on the vector if one or both of the vector components were reversed by multiplying the .

Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.