Silverlight: The ultimate introduction to WPF animation (blend 4 Development)

Source: Internet
Author: User

This tutorial covers a variety of animations in WPF and Silverlight. First.

In the Declaration, this is not just for everyone to copy, but for everyone to familiarize themselves with the animation effect. This finished product basically covers all the animation effects in SL. If you really want to grasp the animation, I suggest you do it again. It's better to say it.

Well, don't forget to recommend it. Thank you.

Many people should be familiar with this website. I use this case to implement all its animation effects step by step. I believe that the animation level will be greatly improved after you finish it.

Looking at the figure above, we can see that it is composed of several animations. In this section, we start making birds.

Development Environment, blend 4.

1. Create a New silverliht program in blend 4.

2. The bird should be only one part of the animation, so create a folder and create a usercontrol.

3. set the visible area to width: 400, height: 412. at the same time, set the page size to 375*319 (by default, Silverlight will always have a fixed size. To make it expand automatically, it is easy to set height = "640 ", width = "480" can be deleted (or set to auto), but after this processing, use blend to open the XAML file. The visible area is 0, which is inconvenient for selecting objects, at this time, we can add this Mark Mc: ignorable = "D". When we use blend to open it, we will find that the visible area has changed to 640*480, And the runtime can still be automatically expanded)

4. Select the pen tool to draw the bird's tail. Draw a feather with a pen (hold down the Alt key when drawing an arc, and drag when a V shape appears ). After painting, fill the image with a gradient Paint Brush (# fff4df00, # ffb15800 ). At the same time, set the border of the path to 6.

5. Copy the path three times to get a total of four paths. Adjust each path to a proper position, press Ctrl to select four paths, right-click them and combine them into a grid, and name the grid tail.

6. Draw a circle as the body of a bird. Use the elliptical tool and press the Alt key to draw a circle. Fill the circle with a linear gradient (# fff4c900, # ffa15000 ). At this time, you will find that your gradient direction is incorrect. Select the gradient tool to adjust the direction.

7. Copy the circle you just painted and narrow it down slightly. Fill it with a solid color paint brush (# ff8e4903 ). Remove the stroke paint brush and change the transparency to 41%.

8. Copy two circles again, zoom out and fill the circle with a solid color paint brush (# ffffffff ). And change the transparency to 10%.

9. Copy the smallest circle, move it to the proper position, and fill it with a solid color paint brush (# ff000000 ). And change the transparency to 20%. This circle is used as the shadow of the bird's eye. Rename this circle as shadoweye.

10. Copy a circle as the eyes of a bird. Set the circle attributes. The effect is different: If the transparency is not set to 100, the gradient position is incorrect.

11. Draw a bird's mouth. Select the pen tool to draw two triangles. And set properties according. You can use a gradient tool to change the gradient direction. If the bird's mouth is not covered by the body, adjust the position.

12. Draw the bird's feet. Select the elliptical tool, hold down the Shift key, draw a circle, and follow the settings. (Draw the other two feet in the same way)

13. Draw the eyes of a bird. First draw a circle with an ellipse and set the attributes.

14. Use the same method to draw the pupil in the middle. (Merge the two circles into the grid and name them eye_grid)

15. Select the pen tool, draw a crescent, and set the attributes.

(Note that eye_grid has only two ovans and the path is not in it)

16. Draw birds with closed eyes. Use an elliptical tool to draw three gardens with the attributes respectively.

17. Draw a curve with a pen tool. Set the following attributes.

18. Merge the three gardens and one path into a grid and name it eyesclosed. Set the opactity attribute of eyesclosed to 0.

19. Select the pen tool to draw a path. Set the following attributes.

20. Copy path. Set the following attributes. After that, merge the two paths into a grid and name them wingdown.

20. Copy the path in step 19 and move it to the appropriate location. Then, put the changed path in the grid and name it wingup. Set opacity of wingup to 0.

21. here our birds are finished. Put all the elements in a canvas and name them sbird.

22. Press F6 to start the animation design. Click state in the lower left corner of the page and select status manager. The new State group is named loop. Then the new State of the group is named hover.

23. Return to the object and Timeline panel and add a key frame at the zero frame of the sbird element and the Tai element. (The button next to the row 0 is the key frame button)

24. Select the sbird element and set the time pointer to 0.5s (that is, the yellow line ). Then, press and hold the cursor in the direction key to shift the sbird element down for a certain distance.

25. Adjust the Time Pointer to 1 s, and then hold down the cursor in the direction key to bring the sbird element back to its original position. (Tip: You can first select the sbird element in the Key Frame of 0 s, right-click and select copy, and then adjust the time pointer to 1 s and press Ctrl + V ).

26. Select the tail element and set the time pointer to 0.5s. In the transoft category area of the properties panel, select convert. Fill in the angle to the margin of your tail swing.

27. Keep the tail element in the selected state, and then adjust the time pointer to 1 s. Enter 0 at angle, and the bird's tail changes back to the original shape.

28. Click the key frame at 0 s, and the attribute panel appears on the right to change easing. (Two key frames at 0 s !)

29. Click the key frame at 0.5s. Set attributes. (The attributes of the 0.5s pointer settings are the same ).

30. Click the 1 s key frame and repeat the 29 steps. Set the property. After that, you can click the play button to check the effect. Is the bird moving up or down. In the last step, click hover and set the repeatbehavior attribute to forever on the property panel.

31. Let the birds blink their eyes. In the lower-left State panel, create a new state group named "eye" and create two new States named "Blink" and "noblink" respectively. Select blink to start the animation.

32. Select the eyesclosed element and set the key frame at 0, 1, 1.03, 1.18, 1.21, 3.7, 3.73, 3.89, 3.92, 4.8, and 4.83 respectively.

33. Keep the eyesclosed element as the selected key frame, click 1.03, 1.18, 3.73, 3.89, 4.83, 4.99, and 100 respectively, and set the opacity attribute of the eyesclosed element.

34. Click each key frame and modify the attributes of each key frame.

35. After the operation, press the "yellow" button to check if the bird is starting to blink. Select Bink and set the repeatbehavior attribute to forever on the property panel. In the last step, let the birds fly.

36. Click the State panel in the lower left corner, and name the new State group wing. Then, name the new State as wings.

37. Select the wingdown element and set the key frame at 0, 0.1, 0.117, and 0.233. (Perform the same processing on wingup elements)

38. First, keep the wingdown element selected, and then modify the opacity attribute of the wingdown element at 0.117s. Change opacity to 0.

39. Keep the wingup element selected, and modify the opacity attribute of the wingup element at 0.117s. Change opacity to 100.

40. Select wings and set the repeatbehavior attribute to forever on the property panel.

41. Finally, let your bird run on the page. Press F6 to exit the Animation Mode and write code in. Copy the Code directly without.

42. Add the loaded event to the outermost layoutroot.

43. Write events in the CS file of bird.

44. Open the appapp. XAML. CS file and make some changes to the application_startup event.

This. rootvisual = new bird (); here, the bird is the project you want to start. For example, there is a cat file in your project as the startup Item. Here, cat is used.

45. Finished. Press F5 to see your bird on the page.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.