TAILIEUCHUNG - Foundation Silverlight 3 Animation- P15

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 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 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. new EventHandler MoveParticles 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. 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 1 if particle 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

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã 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.