[0035] Hereinafter, the present invention will be described in detail with reference to the drawings and in conjunction with the embodiments. It should be noted that the embodiments in the application and the features in the embodiments can be combined with each other if there is no conflict.
[0036] In the method for generating animation in this application, various pictures are used and various actions are added to the pictures to realize the animation. In this application, the desired animation effect is achieved by defining and designing the action behavior of each picture.
[0037] Such as figure 1 The method of generating animation shown in this application includes:
[0038] Step 101: Save multiple pictures used to generate animation;
[0039] The animation in this application contains multiple pictures and animation description files (described below). The multiple pictures saved in this application for generating animation can be combined with multiple pictures into a combined picture, and a picture description file is generated for the combined picture. The picture description file records the difference of each picture in the combined picture. Size and location. When pictures need to be used, the pictures are obtained from the combined pictures according to the size and position of each picture recorded in the picture description file of the combined pictures. The size of the original file of each picture can also be recorded in the picture description file. The map description file can be an xml file. Of course, the pictures included in the animation in this application can also be saved separately.
[0040] In this application, combining multiple pictures into one combined picture can optimize the animation performance and reduce a lot of memory that needs to be loaded by the application. The more pictures combined into a combined picture, the more obvious the performance optimization.
[0041] Step 102: Generate an animation description file for describing the animation layout and the action behavior of the picture. The animation description file records the layout information, action behavior description information and execution control information of each picture.
[0042] In this application, it is very important to realize the animation description file. Step 102 is to describe the layout of each picture in the animation and the action behavior to be realized into a description that the computer program can understand.
[0043] The layout information in the animation description file is the position information of the picture in the animation. For example, the layout information of each picture may be based on the position of one picture, and position information of other pictures relative to the reference picture.
[0044] The action description information in the animation description file includes: action type information and action parameter information. For example, the action type can include: rotation, movement, and deformation. Action parameter information is different for different action types, such as rotation (Rotation), action parameter information can be rotation angle, rotation direction, etc.; for deformation, it can also be called scale, and action parameter information can be a picture The zoom information; for movement, it can also be called position transformation. The action parameter information can be such as the movement from left to right, top to bottom, from one point to another on the screen, etc., and can also include key frame movement , Picture moving speed and other information.
[0045] The execution control information includes: execution sequence information and execution duration information.
[0046] In addition to recording the layout information, action description information, and execution control information of each picture, the animation description file can also contain information such as the total duration of the animation and the number of executions. The animation description file can be in xml format.
[0047] In this application, the combined picture, the combined picture description file and the animation description file can be placed on the server. After the client downloads, the dynamic animation effect can be realized by analyzing the picture and the corresponding action behavior.
[0048] In the following, the method of the present application will be described by taking an animation of a train pulling a car of red hearts from right to left as an example.
[0049] The content involved in the animation includes:
[0050] (1) The red heart will flash and beat continuously;
[0051] (2) Each wheel rotates and moves from right to left;
[0052] (3) The gray heart drifts upward and fades away, just like the chimney of a train;
[0053] (4) The movement of the carriage, the front of the car, the red heart, the wheel, the frustration, and the car body must be synchronized and consistent.
[0054] For the realization of the above animation, first of all, each small picture is formed into a combined picture, and a picture description file is generated at the same time. The information of each picture is recorded in the picture description file, such as the position and size of the picture, and the original picture File size, etc.
[0055] Secondly, an animation description file must be generated, which records the layout information, action description information and execution control information of each picture.
[0056] Action description information, such as the rotation of the wheel, the angle and direction of the wheel rotation, etc.; the flashing of the red heart, the zoom information of the red heart; the position change of the various parts of the train and the red heart and the gray heart, such as from left to Right movement, movement speed, etc.
[0057] The layout information of each picture, such as the position of the train body as a reference, and the position information of other pictures relative to the train body.
[0058] The execution control information of each picture, such as the execution sequence and execution duration of the train movement and the red heartbeat.
[0059] The animation description file can also record the total execution time and execution times of the animation. For example, in the above animation, the time for the train to travel across the screen width from left to right, the number of executions of the animation, etc.
[0060] The above information generates an animation description file in xml format according to the format, and the client can display the corresponding animation after obtaining the file.
[0061] Such as figure 2 As shown, this application also provides a method for displaying animation, including:
[0062] Step 201: Acquire multiple pictures and corresponding animation description files used to generate animation, where the animation description file is used to describe the animation layout and the action behavior of the pictures;
[0063] In this application, acquiring multiple pictures may be obtained by first acquiring a combined picture formed by combining multiple pictures and a picture description file corresponding to the combined picture; and then according to the size and size of each picture recorded in the picture description file in the combined picture Location, the picture is obtained from the combined picture.
[0064] Step 202: According to the layout information, action behavior description information and execution control information of each picture recorded in the animation description file, the animation layout and the action behavior of each picture are realized, and the animation effect is displayed.
[0065] In this application, the layout information recorded in the animation description file is the position information of the picture in the animation; the action behavior description information includes: action type information and action parameter information; execution control information includes: execution sequence information and execution duration information.
[0066] Such as image 3 As shown, this application also provides a device for generating animation, including: a picture processing unit and an animation description file generating unit, wherein:
[0067] Picture processing unit for saving multiple pictures used to generate animation;
[0068] The animation description file generating unit is used to generate an animation description file for describing the animation layout and the action behavior of the picture. The animation description file records the layout information, action description information and execution control information of each picture.
[0069] The animation description file generating unit saves multiple pictures used to generate animation, including: merging multiple pictures into a combined picture, generating a picture description file for the combined picture, and recording each picture in the combined picture in the picture description file Size and position.
[0070] The layout information recorded in the animation description file is the position information of the picture in the animation; the action description information includes: action type information and action parameter information; execution control information includes: execution sequence information and execution duration information.
[0071] Such as Figure 4 As shown, this application also provides a device for displaying animation, including: an acquisition unit and a display unit, wherein:
[0072] The obtaining unit is used to obtain multiple pictures used to generate animation and corresponding animation description files, the animation description files are used to describe the animation layout and the action behavior of the pictures;
[0073] The display unit is used to realize the animation layout and the action behavior of each picture according to the layout information, action description information and execution control information of each picture recorded in the animation description file, and display the animation effect.
[0074] The acquiring unit acquires multiple pictures used to generate animation, including: acquiring a combined picture formed by combining multiple pictures and a picture description file corresponding to the combined picture; according to the size and size of each picture in the combined picture recorded in the picture description file Location, get the picture from the combined picture.
[0075] Those skilled in the art should understand that the above-mentioned modules or steps of the present invention can be implemented by a general computing device. They can be concentrated on a single computing device or distributed on a network composed of multiple computing devices. Optionally, they can be implemented with program codes executable by the computing device, so that they can be stored in the storage device for execution by the computing device, and in some cases, they can be executed in a different order than here. The steps shown or described can be implemented by fabricating them into individual integrated circuit modules, or fabricating multiple modules or steps into a single integrated circuit module. In this way, the present invention is not limited to any specific combination of hardware and software.
[0076] The above descriptions are only preferred embodiments of the present invention and are not used to limit the present invention. For those skilled in the art, the present invention may have various modifications and changes. Any modification, equivalent replacement, improvement, etc., made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
[0077] Although the present invention is described in detail above, the present invention is not limited thereto, and those skilled in the art can make various modifications according to the principles of the present invention. Therefore, all modifications made in accordance with the principles of the present invention should be understood as falling within the protection scope of the present invention.