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

Không đóng trình duyệt đến khi xuất hiện nút TẢI XUỐNG

Foundation Silverlight 3 Animation- P15: 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. | PARTICLE SYSTEMS 9. Compile and run the program. You will see something like what is shown in Figure 10-3. Figure 10-3. The particles now have random color scale and opacity. 10. So the particle generator is in place and does a pretty good job of randomizing our particles but at this point they re static. We need to make them move. Let s start by adding age and life span to each particle. Open the Particle.xaml.es file and add the following lines of code before the Particle constructor. These are two simple publicly accessible properties that will be used to track a particle s age and life span. public int Age get set public int LiteSpan get set 11. Back in MainPage.xaml.es add the following two lines at the bottom of the MainPage constructor. These lines of code will set up an event listener for our Timer storyboard and start the storyboard running. Move.Completed new EventHandler MoveParticles Move.Begin 401 CHAPTER 10 12. Inside the CreateParticles function add the following line which will create a random life span between 0 and 120 frames for each particle as it is created. At 30 frames per second that should be a maximum of 4 seconds that any given particle is on the screen. particle.LifeSpan Rand.Next 120 13. The MoveParticles event handler is shown following. This code uses the foreach loop to step through each particle in the Particles List increment the age and test to see if the particle has reached its life span. If so the particle is removed from the main canvas. private void MoveParticles object sender EventArgs e foreach Particle particle in Particles particle.Age 1 if particle.Age particle.LifeSpan LayoutRoot.Children.Remove particle Move.Begin 14. Compile and run the project. The particles will be drawn and after a second or so will start disappearing from the screen until they re all gone. 15. Each time a particle dies we ll create a new one. To do this we ll first need to make a change to the MoveParticles code however. The foreach loop locks up

Đã 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.