Animation implementation method and apparatus, and electronic device and storage medium
Through the animation management factory class, the creation and use of animation management objects is solved, and the code maintenance problem caused by the diverse animation implementation methods in the car computer system is realized, the modularity and reusability of the animation code is realized, and the flexibility and maintainability of the system are enhanced.
Patent Information
- Application Number
- PCT/CN2024/102005
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-08-30
- Filing Date
- 2024-06-27
- Publication Date
- 2025-03-06
AI Technical Summary
In the car computer system, the implementation methods of animation are diverse, resulting in each animation method corresponding to an independent set of code, which is very laborious to maintain and is difficult to flexibly switch and reuse.
Through the animation management factory class, the creation and use of animation management objects are separated, the coupling between business logic and specific animation implementation is reduced, and the flexible switching and multiplexing of different animation types is achieved.
The modularity and reusability of animation code is realized, the maintenance complexity is reduced, the system is enhanced, and the flexibility and maintainability is enhanced, making it easier to adapt to changes and expansion.
Smart Images

Figure CN2024102005_06032025_PF_FP_ABST
Abstract
Description
Animation implementation method, device, electronic device and storage medium
[0001] This application claims priority to the Chinese patent application filed with the State Intellectual Property Office on August 30, 2023, with application number 202311107359.4 and application name “A method, device, electronic device and storage medium for animation implementation”, the entire contents of which are incorporated by reference into this application. Technical Field
[0002] The present application relates to the field of computer technology, and in particular to an animation implementation method, device, electronic device, and storage medium in the field of computer technology. Background Art
[0003] In a car system with a built-in Android operating system, the UI (User Interface) of the car system can be expressed with animation to visually convey complex status and interaction information and enhance the user experience. For example, the air conditioning blowing effect, energy flow status, and virtual image movement display in the car system. However, there are many ways to implement animation, such as frame animation, Lottie animation, 3D animation, etc. Each animation usually requires different coding and resources, and different car models may use different animation implementation methods. In the traditional development process, although the business logic processing process of the same animation effect is the same or similar, each animation method often corresponds to a separate set of codes. If the requirements change during the development process, the workload of code maintenance is large.
[0004] Summary of the Invention
[0005] The present application provides an animation implementation method, device, electronic device and storage medium. The method separates the creation and use of animation management objects through an animation management factory class, reduces the coupling between business logic and specific animation implementation, and is easier to maintain and expand.
[0006] In a first aspect, the present application provides an animation implementation method, which includes: obtaining the animation type of the target animation; constructing an animation management object corresponding to the animation type through an animation management factory class; and determining the target animation based on the animation management object and animation parameter information of the target animation.
[0007] In one possible implementation, an animation management object corresponding to an animation type is constructed through an animation management factory class, including: determining the animation management class corresponding to the animation type through the animation management factory class; instantiating the animation management class through the animation management factory class, and constructing the animation management object corresponding to the animation management class.
[0008] In one possible implementation, before determining the animation management class corresponding to the animation type through the animation management factory class, it includes: encapsulating the animation management factory class, and defining the animation management class corresponding to the animation type; wherein the animation management factory class encapsulates the method of constructing the animation management object, and the animation management class defines the animation type and the animation management properties corresponding to the animation type.
[0009] In a possible implementation, animation management classes corresponding to different animation types inherit from the same animation management base class.
[0010] In a possible implementation, before determining the animation management class corresponding to the animation type through the animation management factory class, the method further includes: defining an animation management base class; wherein the animation management base class defines animation playback logic and animation view acquisition method.
[0011] In a possible implementation, the animation parameter information includes animation playback control information and animation playback content information.
[0012] In a possible implementation, after determining the target animation based on the animation management object and the animation parameter information of the target animation, the method further includes: outputting the view component carrying the target animation to the user interface layer for display.
[0013] In a second aspect, the present application provides an animation implementation device, the device comprising:
[0014] The acquisition module is used to obtain the animation type of the target animation;
[0015] Construction module, used to construct animation management objects corresponding to animation types through animation management factory classes;
[0016] The determination module is used to determine the target animation based on the animation management object and the animation parameter information of the target animation.
[0017] In a possible implementation, the building blocks include:
[0018] An identification unit, used to determine the animation management class corresponding to the animation type through the animation management factory class;
[0019] The construction unit is used to instantiate the animation management class through the animation management factory class and construct the animation management object corresponding to the animation management class.
[0020] In one possible implementation, the device further includes:
[0021] The first definition module is used to encapsulate the animation management factory class and define the animation management class corresponding to the animation type; wherein the animation management factory class encapsulates the method of constructing the animation management object, and the animation management class defines the animation type and the animation management properties corresponding to the animation type.
[0022] In a possible implementation, animation management classes corresponding to different animation types inherit from the same animation management base class.
[0023] In one possible implementation, the device further includes:
[0024] The second definition module is used to define the animation management base class; wherein the animation management base class defines the animation playback logic and the animation view acquisition method.
[0025] In a possible implementation, the animation parameter information includes animation playback control information and animation playback content information.
[0026] In one possible implementation, the device further includes:
[0027] The display module is used to output the view component carrying the target animation to the user interface layer for display.
[0028] In a third aspect, the present application provides an electronic device comprising a memory and a processor. The memory is configured to store executable program code, and the processor is configured to retrieve and execute the executable program code from the memory, so that the electronic device executes the method of the first aspect or any possible implementation of the first aspect.
[0029] In a fourth aspect, the present application provides a computer program product, which includes: computer program code, which, when running on a computer, enables the computer to execute the method in the above-mentioned first aspect or any possible implementation of the first aspect.
[0030] In a fifth aspect, the present application provides a computer-readable storage medium storing a computer program code. When the computer program code runs on a computer, the computer executes the method in the above-mentioned first aspect or any possible implementation of the first aspect.
[0031] In summary, in the technical solution of the present application, the animation type of the target animation is obtained; an animation management object corresponding to the animation type is constructed through the animation management factory class; and the target animation is determined based on the animation management object and the animation parameter information of the target animation. This method uses the animation management factory class to separate the creation and use of the animation management object, thereby reducing the coupling between the business logic and the specific animation implementation, and achieving flexible switching and reuse of different animation types. In this way, whether changing existing animations or adding new animation types, it can be achieved quickly and flexibly, enhancing the flexibility and maintainability of the system, making it easier to adapt to changes and expansions, and meeting the animation display needs of different scenarios and requirements. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] FIG1 is an exemplary system architecture diagram of an animation implementation system provided in an embodiment of the present application;
[0033] FIG2 is a schematic flow chart of an animation implementation method provided in an embodiment of the present application;
[0034] FIG3 is a schematic interactive flow chart of an animation implementation method provided in an embodiment of the present application;
[0035] FIG4 is a schematic diagram of class dependencies in an animation control layer provided by an embodiment of the present application;
[0036] FIG5 is a structural diagram of an animation implementation device provided in an embodiment of the present application;
[0037] FIG6 is a schematic structural diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0038] An embodiment of the present application provides an animation implementation method. The implementation of this method relies on a computer program that can be run on an animation implementation device or animation implementation system based on the von Neumann architecture. The computer program can be integrated into an application or run as a standalone tool application. The animation implementation device can be a terminal device, including but not limited to: a personal computer, a tablet computer, a handheld device, an in-vehicle device, a wearable device, a computing device, or other processing device connected to a wireless modem.
[0039] In the UI of an in-car system powered by the Android operating system, animation effects can enrich the visual experience and enhance the user experience. Typically, the animation implementation process involves the following steps: first, determining the specific animation effect requirements, such as the air conditioning effect in an in-car system; then, writing specific logic code based on the requirements to determine the animation's start and stop times, as well as the content to be played; then, selecting an animation implementation method based on the specific requirements (such as frame animation or Lottie animation) and writing the specific animation implementation code; and finally, rendering the implemented animation to the screen for display to the user.
[0040] However, different types of animations require different implementation code. For example, frame animations and Lottie animations require different implementation code. Even if the business logic of certain animations is very similar or identical, different animation implementations still need to be written and maintained separately. The business logic of an animation can be high-level logical operations unrelated to the animation's performance and behavior. It involves things like the triggering conditions for the animation, when it starts and ends, and how it responds to user interactions, rather than the specific implementation or details of the animation frames.
[0041] For example, a car navigation system might display an animation before the driver reaches a turn to indicate the direction and distance. The business logic might include: the system detects that the vehicle is 500 meters away from the next turn; the system displays an animation prompt to the driver; and the animation disappears after the driver successfully completes the turn according to the animation prompt.
[0042] Business logic describes when and how to initiate animations and is independent of the specific visual effects and implementation of the "turn prompt" animation. When different types of animations are written and maintained separately, a large amount of business logic code must be rewritten. Modifying the animation business logic or adding a new animation type may require multiple levels of code modifications or the writing of a completely new set of animation implementation code, increasing the complexity of development and maintenance.
[0043] Since the vehicle systems of different models may use different animation implementation methods, in order to better adapt to the diverse needs of different models and scenarios, this application proposes an animation implementation method. This method encapsulates an animation management factory class to separate the creation and use of animation management objects, so as to reduce code redundancy, reduce coupling, and make it easier to maintain and expand.
[0044] FIG1 is an exemplary system architecture diagram of an animation implementation system provided in an embodiment of the present application. As shown in FIG1 , the animation implementation system includes a business logic layer 110 , an animation control layer 120 and a UI presentation layer 130 .
[0045] The business logic layer 110 is the starting point of the entire architecture. The business logic layer 110 is used to determine the key parameter information of the animation that needs to be displayed based on the specific application scenarios and needs. Specifically, the business logic layer 110 can determine the specific type of animation to be displayed by analyzing business needs. The animation type can be different implementation methods such as frame animation, Lottie animation, three-dimensional animation (such as Unity); the business logic layer 110 can pass the animation type to the animation control layer 120, requesting the animation control layer 120 to build the corresponding animation management object; the business logic layer 110 can also provide animation parameter information of the specific animation, such as animation content, playback timing, playback speed, number of repetitions, etc., so that the animation control layer 120 applies the animation parameter information to the animation management object to generate a specific animation instance, that is, the target animation.
[0046] The animation control layer 120 is located between the business logic layer 110 and the UI presentation layer 130, acting as an intermediary layer to manage and control the creation, configuration, and playback of animations. Specifically, the animation control layer 120 can construct corresponding animation management objects based on the animation type received from the business logic layer 110 through the animation management factory class. The animation management factory class encapsulates the construction logic of the animation management object, allowing different types of animation management objects to be constructed through a unified interface. The animation control layer 120 is also used to apply the animation parameter information provided by the business logic layer 110 to specific animation management objects to generate the corresponding animation.
[0047] The UI presentation layer 130, as the front end of the entire architecture, is used to present the animation provided by the animation control layer 120 to the user, enabling user interaction with the animation. Specifically, the UI presentation layer 130 can manage the view portion of the animation, render the animation view component returned by the animation control layer 120 onto the screen, and control the animation's position, size, transparency, and other visual attributes; the UI presentation layer 130 can be responsible for processing user interactions with the animation, such as clicks, slides, and other operations, which can trigger the animation to play, pause, or other effects; the UI presentation layer 130 is also used to feed back the animation's status or progress to the business logic layer 110 for further logical processing.
[0048] For example, if the air-conditioning blowing effect needs to be displayed in the car system, frame animation is chosen to display this effect according to the specific requirements of the effect. At this time, the business logic layer will determine that the animation type is "frame animation". The business logic layer will pass the "frame animation" type to the animation control layer and request the construction of a corresponding frame animation management object. After determining to use frame animation to display the air-conditioning blowing effect, the business logic layer also provides animation parameter information such as animation resources, playback speed, and playback timing. After the animation control layer constructs the corresponding frame animation management object, the frame animation management object generates the air-conditioning blowing effect animation by loading and configuring the animation parameter information. Finally, the animation control layer returns the view component (View) containing the air-conditioning blowing effect animation to the UI display layer. The UI display layer adds the view component to the UI layout and adjusts its size or transparency as needed so that it can be rendered to a specific position in the user interface when used.
[0049] Next, with reference to Figure 1, the animation control layer is used as the execution body to introduce the animation implementation method provided by the embodiment of the present application. Please refer to Figure 2 for details, which is a schematic flow chart of an animation implementation method provided by the embodiment of the present application. For example, as shown in Figure 2, the animation implementation method includes the following steps:
[0050] S201: The animation control layer obtains the animation type of the target animation.
[0051] Specifically, different animation types are suitable for different scenarios and needs. If the animation implementation system supports multiple animation types, the most appropriate animation implementation method (animation type) can be selected for specific needs and environments, so that the selected animation matches the desired visual effects and functional requirements. In addition, different animation types may have different resource and performance requirements. For example, 3D animation may require stronger graphics processing capabilities, while frame animation may require more storage space. Choosing the right animation type helps write more targeted code and facilitates subsequent maintenance. It can also enhance the user experience, making the animation appear smoother, more natural, and more interactive.
[0052] Targeted animation refers to animations that are used to achieve a specific visual effect or functional purpose. For example, the visual effect of an air conditioner blowing air or the feedback effect of a button click can both be targeted animations. Targeted animations represent the specific effect you want to show the user on the screen.
[0053] Animation Type refers to the specific technology or implementation method used to achieve the target animation. Each type of animation has its own unique display method, technical implementation, and resource requirements. The embodiments of this application can obtain the following animation types, including but not limited to:
[0054] Frame Animation: Consists of a series of individual images or frames, played in a specific order and rate, and can be used for complex animation effects.
[0055] Lottie Animation: Lottie is a library that parses Adobe After Effects animations and renders them on mobile devices and web pages, suitable for complex animation effects.
[0056] Unity Animation: Unity is an engine widely used in game development. It provides powerful 3D rendering capabilities and a physics engine. It can be used to create various interactive 3D content and virtual reality applications, achieving realistic 3D animation effects.
[0057] Kanzi Animation: Kanzi is a development tool for creating user interfaces for cars and embedded devices. It provides a visual editing environment for designing and building interfaces with complex animations and interactions.
[0058] In this embodiment, by obtaining the animation type of the target animation, subsequent animation management object construction can be performed based on the animation type, so that when the implementation method of the target animation needs to be modified, only the animation type needs to be modified.
[0059] S202: The animation control layer constructs an animation management object corresponding to the animation type through the animation management factory class.
[0060] Specifically, the animation management factory class adopts the factory design pattern. Based on the input animation type, it can flexibly construct animation management objects corresponding to the animation type through internally encapsulated construction logic. The animation management object can manage and control the interface of its corresponding specific type of animation (such as frame animation, Lottie animation, etc.), and control the animation playback, pause and other operations through its internally encapsulated methods and properties. It can also manage animation properties such as resources and speed. This decouples the specific implementation of the animation from the business logic layer (main program), allowing the business logic layer to control different types of animations through a unified interface. The addition and modification of animation types does not affect other logic codes, which realizes the modularization and reusability of the code and improves the maintainability and scalability of the code.
[0061] For example, in developing an in-vehicle infotainment system, in some cases, the in-vehicle infotainment system may need to display animation effects, for example: when the vehicle starts, display a frame animation of the brand logo; when the music player switches songs, display a Lottie animation of a record turning effect.
[0062] When the vehicle starts, the business logic layer requests the "frame animation" type and provides the brand logo resource. The animation control layer then uses the animation management factory class to create an animation management object corresponding to the requested "frame animation" and configures the animation parameters based on the provided resources. Once configured, the business logic layer can control the playback of the frame animation by calling the animation management object's specified method, such as "Play."
[0063] When the music player switches songs, the business logic layer similarly requests the "Lottie animation" type and provides the album animation resources. The animation control layer then uses the animation management factory class to create an animation management object corresponding to the "Lottie animation" requested and configures the animation parameters based on the provided resources. Once configured, the business logic layer can control the playback of the Lottie animation by calling the animation management object's specified methods, such as "Play."
[0064] In both scenarios, the business logic layer's invocation method is consistent; only the requested animation type and resources differ. This allows us to add more animation types in the future by simply extending the animation management factory class and adding the corresponding animation management objects. For example, when receiving a navigation instruction to display a 3D animated turn arrow, the business logic layer's invocation logic remains consistent. The business logic layer doesn't need to be modified to support new animation types, as it relies solely on the unified interface provided by the animation management factory class.
[0065] In one possible implementation, the animation control layer constructs the animation management object corresponding to the animation type through the animation management factory class, including: the animation control layer determines the animation management class corresponding to the animation type through the animation management factory class; the animation control layer instantiates the animation management class through the animation management factory class to construct the animation management object corresponding to the animation management class.
[0066] Specifically, the animation management factory class determines the animation management class used to implement the input animation type. Animation types and animation management classes can be associated through mappings and other methods. After determining the animation management class, the animation management factory class instantiates it according to the animation management class definition to construct a specific animation management object. Because the creation and configuration of animation management objects are encapsulated within the animation management factory class and the animation management class, the code that calls them remains concise and consistent, while also providing greater flexibility and scalability.
[0067] For example, if a frame animation is needed to show a certain effect, you can select the frame animation management class through the animation management factory class, then instantiate the frame animation management class, return a constructed frame animation management object, and then implement frame animation playback by calling the playback animation logic of the frame animation management object.
[0068] The animation management class is used to define the properties and behaviors of a specific type of animation. The animation management class encapsulates all the characteristics and control logic of this type of animation and provides a template for creating animation management objects with the same properties and methods, thereby achieving unified management of a specific type of animation.
[0069] In one possible implementation, before the animation control layer determines the animation management class corresponding to the animation type through the animation management factory class, it includes: the animation control layer encapsulates the animation management factory class, and defines the animation management class corresponding to the animation type; wherein the animation management factory class encapsulates the method of constructing the animation management object, and the animation management class defines the animation type and the animation management properties corresponding to the animation type.
[0070] Specifically, the animation management factory class encapsulates the method of constructing the animation management object, and all details related to the construction of the animation management object are hidden inside the factory class. This encapsulation separates the creation and use of the animation management object. Other parts of the animation implementation system (such as the business logic layer) do not need to know how to instantiate or configure a specific animation management class. It only needs to know the required animation type, and then request the animation management factory class to create an animation management object of that animation type, and directly call the created animation management object. In this way, the present application can hide the complexity of creating animation management objects, make the code neater, and improve the scalability and maintainability of the code. In addition, since the present application concentrates the creation logic of the animation management object in one place, it is easier to track and modify.
[0071] For example, when developing an in-vehicle infotainment system, there may be multiple animation effects, such as startup animation, navigation path animation, and music playback animation, which may involve multiple animation types. When adding or modifying animation types, using the animation management factory class, you only need to add or modify the creation logic of the corresponding animation management object in the factory class, without touching other code that uses animations. This not only reduces the chance of errors but also makes the animation implementation system more responsive and flexible in supporting new animation types.
[0072] Animation management properties can be a set of properties and parameters used to manage and control animations. They may include but are not limited to:
[0073] Playback control properties: such as playback speed, number of plays, looping, etc.
[0074] Animation resource properties: For example, the path or reference to resources such as images, audio, and data files required for the animation.
[0075] Animation effect properties: such as animation transparency, position, size, color and other visual effect control parameters.
[0076] State properties: such as the current state of the animation (playing, paused, stopped, etc.).
[0077] Defining animation manager classes provides a structured approach to managing different types of animations. Each type of animation has its own manager class, encapsulating the properties and methods specific to that type of animation. This avoids cluttering all animation logic, improving code clarity and maintainability. When adding or modifying functionality for a specific animation type, this allows for more flexibility and targeted operation, improving development efficiency and code quality.
[0078] In a possible implementation, animation management classes corresponding to different animation types inherit from the same animation management base class.
[0079] Specifically, inheritance refers to a new class receiving (inheriting) the properties and methods of another class. Inheritance helps structure and organize related classes, ensuring code reusability and maintainability. When animation management classes corresponding to different animation types inherit from the same base class, all animation management classes have a unified interface and share the same set of methods and properties. This means that regardless of the specific animation type, calling code can interact with the animation management object in the same way. Furthermore, if there are common features or properties that apply to all animation types, these features can be defined in the base class and then shared by all animation management classes, eliminating duplication and reducing maintenance complexity. For example, when adding a new type of animation management class, you only need to inherit from the base class without rewriting existing code. When changing a common feature, you only need to modify the base class, and all animation management classes that inherit from it will be updated.
[0080] In a possible implementation, before the animation control layer determines the animation management class corresponding to the animation type through the animation management factory class, it also includes: defining an animation management base class; wherein the animation management base class defines animation playback logic and animation view acquisition method.
[0081] Specifically, the animation management base class serves as the parent class of various types of animation management classes. The animation management base class provides a set of common properties and methods, which helps ensure that all animation management objects follow the same interface. In this embodiment, the animation management base class defines animation playback logic and animation view acquisition method. The animation playback logic is used to control the playback of the animation, such as play, pause, stop, loop, etc. This method will control the animation playback process according to the requirements and configuration of the animation. The function of the animation view acquisition method is to return the view component of the animation. This view component can be added to the UI layout to render the animation at a specific location in the user interface.
[0082] S203: The animation control layer determines the target animation based on the animation management object and the animation parameter information of the target animation.
[0083] Specifically, an animation management object is constructed from an animation management factory class and is used to manage and control animations of a specific type. Animation management objects have animation management properties related to a specific animation type, allowing for detailed configuration of the animation's playback and presentation. The target animation's animation parameter information is used to determine its playback and presentation, including animation playback control information and animation playback content information. Animation playback control information describes the logical structure (i.e., business logic) for playing an animation according to specific rules and sequences, and may include playback order, playback speed, loop control, trigger conditions, and more. Animation playback content information covers the animation resources required for the actual animation presentation, including image resources, sound resources, 3D models, text content, and more. After loading and configuring the animation parameter information, the animation management object generates a target animation of the corresponding animation type and controls its playback. The animation view retrieval method returns a view component that hosts the target animation, rendering the animation on the screen and enabling user interaction with the animation. A view component that hosts the target animation is then returned.
[0084] In a possible implementation, after the animation control layer determines the target animation based on the animation management object and the animation parameter information of the target animation, the method further includes: outputting the view component carrying the target animation to the user interface layer for display.
[0085] Specifically, after the target animation is created and configured, the animation implementation system needs to display the generated animation to the user. The view component that hosts the target animation can be a specific view or control. The animation manager generates the target animation by loading and configuring the animation parameters and then embeds it into the view component. Once the target animation is embedded in the view component, it can be added to the user interface layer.
[0086] The user interface layer (UI presentation layer) interacts directly with the user, managing and displaying all visible components and controls. This layer can include various layouts, buttons, text boxes, and other elements, with the view component that hosts the animation becoming part of it. By integrating this component into the user interface layer, the target animation can be rendered and presented intuitively to the user. This approach not only makes adding and configuring animations flexible and convenient, but also helps maintain consistency and maintainability across the entire user interface.
[0087] In the technical solution of this application, the animation type of the target animation is obtained; an animation management object corresponding to the animation type is constructed using an animation management factory class; and the target animation is determined based on the animation management object and the animation parameter information of the target animation. This method uses an animation management factory class to separate the creation and use of animation management objects, thereby reducing the coupling between business logic and specific animation implementations and enabling flexible switching and reuse of different animation types. This allows both changing existing animations and adding new animation types to be done quickly and flexibly, enhancing the flexibility and maintainability of the animation implementation system, making it easier to adapt to changes and expansions, and meeting the animation display needs of different scenarios and requirements.
[0088] Next, please refer to Figure 3, which is a schematic interactive flow chart of an animation implementation method provided in an embodiment of the present application. Exemplarily, as shown in Figure 3, the animation implementation method includes the following steps:
[0089] S301: The business logic layer sends the animation type to the animation control layer.
[0090] Specifically, the business logic layer will determine the animation type of the required animation (such as frame animation, Lottie animation, etc.) according to specific needs and scenarios, and send the animation type information to the animation control layer as the basis for constructing the animation management object.
[0091] S302: The animation control layer constructs an animation management object according to the animation type.
[0092] Specifically, after receiving the animation type, the animation control layer constructs the corresponding animation management object through the animation management factory class. The animation management object encapsulates common operations such as play and pause, as well as specific properties of the animation type.
[0093] FIG4 is a schematic diagram of class dependency relationships in an animation control layer provided by an embodiment of the present application. For example, as shown in FIG4 ,
[0094] AnimationManagerFactory is an animation management factory class;
[0095] createManager(animation Type) is a factory method that can create a corresponding animation management object based on the provided animation type. The animation management object is based on BaseAnimationManager.
[0096] BaseAnimationManager is an animation management base class that provides the basic framework and common functions of animation management and can be inherited by animation management classes of different animation types.
[0097] playAnimation(animation) is a general method for playing animation;
[0098] getAnimationView():View is a general method for getting the view component that hosts the animation.
[0099] FrameAnimationManager is the animation management class corresponding to the frame animation type;
[0100] LottieAnimationManager is the animation management class corresponding to the Lottie animation type;
[0101] UnityAnimationManager is the animation management class corresponding to the Unity animation type;
[0102] KanziAnimationManager is the animation management class corresponding to the Kanzi animation type;
[0103] Among them, field:type is used to describe the specific frame animation type, and the animation management class includes the logic and properties unique to the corresponding animation type.
[0104] In the animation control layer, the AnimationManagerFactory class uses the createManager method to create an animation manager object of the corresponding animation manager class based on the provided animation type. For example, if the animation type is frame animation, an instance of the FrameAnimationManager class can be created. These animation manager classes inherit from the BaseAnimationManager class, ensuring that they share a common interface and behavior, thereby enhancing code flexibility and maintainability.
[0105] S303: The business logic layer sends the animation parameter information to the animation control layer.
[0106] Specifically, when an animation management object is created, the business logic layer determines the animation playback parameters based on specific requirements. These parameters include animation playback control information and animation content information, such as playback speed, number of plays, and resource path. The business logic layer sends these parameters to the animation control layer for configuring the target animation.
[0107] It should be noted that the business logic layer can send the animation parameter information and the animation type to the animation control layer at the same time.
[0108] S304: The animation control layer configures the target animation according to the animation parameter information and the animation management object.
[0109] Specifically, the animation control layer uses the received animation parameters and the constructed animation management object to determine and configure the target animation. The target animation configuration process may include loading resources, setting playback properties, applying visual effects, and other steps.
[0110] S305: The animation control layer returns the view component carrying the target animation to the UI presentation layer.
[0111] Specifically, after the target animation is configured, the animation control layer embeds the target animation into a specific view component (View) and returns this component to the UI presentation layer, allowing the target animation to be displayed as part of the interface.
[0112] S306: The UI presentation layer adds the view component to the UI layout.
[0113] Specifically, the UI presentation layer adds the received view components to the UI layout, enabling the animation to be rendered and displayed on the user interface, ensuring the consistency and coordination between the animation and other UI elements, and also providing a basis for subsequent interactions.
[0114] The entire animation implementation process covers the complete process of defining animation requirements through the business logic layer, building and configuring animations through the animation control layer, and displaying animations through the UI presentation layer. Through the animation implementation method, the business logic layer and the animation control layer are decoupled, which is compatible with many different types of animations and has strong scalability and maintainability. For example, if you want to switch the current animation to another animation type, you only need to modify the animation type passed from the business logic layer to the animation control layer to complete the switch. If you want to add a new animation type, you only need to add the corresponding animation management class in the animation control layer, without modifying the core logic code of the business logic layer and the UI layer code.
[0115] FIG5 is a schematic structural diagram of an animation implementation device provided in an embodiment of the present application.
[0116] Exemplarily, as shown in FIG5 , the apparatus 500 includes:
[0117] An acquisition module 510 is used to acquire the animation type of a target animation;
[0118] A construction module 520 is used to construct an animation management object corresponding to the animation type through an animation management factory class;
[0119] The determination module 530 is configured to determine the target animation based on the animation management object and the animation parameter information of the target animation.
[0120] In one possible implementation, the building block 520 includes:
[0121] An identification unit, used to determine the animation management class corresponding to the animation type through the animation management factory class;
[0122] The construction unit is used to instantiate the animation management class through the animation management factory class and construct the animation management object corresponding to the animation management class.
[0123] In a possible implementation, the apparatus 500 further includes:
[0124] The first definition module is used to encapsulate the animation management factory class and define the animation management class corresponding to the animation type; wherein the animation management factory class encapsulates the method of constructing the animation management object, and the animation management class defines the animation type and the animation management properties corresponding to the animation type.
[0125] In a possible implementation, animation management classes corresponding to different animation types inherit from the same animation management base class.
[0126] In a possible implementation, the apparatus 500 further includes:
[0127] The second definition module is used to define the animation management base class; wherein the animation management base class defines the animation playback logic and the animation view acquisition method.
[0128] In a possible implementation, the animation parameter information includes animation playback control information and animation playback content information.
[0129] In a possible implementation, the apparatus 500 further includes:
[0130] The display module is used to output the view component carrying the target animation to the user interface layer for display.
[0131] In summary, in the technical solution of the present application, the animation type of the target animation is obtained; an animation management object corresponding to the animation type is constructed through an animation management factory class; and the target animation is determined based on the animation management object and the animation parameter information of the target animation. This method uses an animation management factory class to separate the creation and use of animation management objects, thereby reducing the coupling between business logic and specific animation implementations and enabling flexible switching and reuse of different animation types. In this way, whether changing existing animations or adding new animation types, it can be done quickly and flexibly, enhancing the flexibility and maintainability of the animation implementation system, making it easier to adapt to changes and expansions, and meeting the animation display needs of different scenarios and requirements.
[0132] FIG6 is a schematic structural diagram of an electronic device provided in an embodiment of the present application.
[0133] Exemplarily, as shown in FIG6 , the electronic device 600 includes a memory 610 and a processor 620 , wherein the memory 610 stores an executable program code 611 , and the processor 620 is configured to call and execute the executable program code 611 to perform an animation implementation method.
[0134] In this embodiment, the electronic device can be divided into functional modules according to the above-described method example. For example, each functional module can be mapped to a specific function, or two or more functions can be integrated into a single processing module. The integrated module can be implemented in hardware. It should be noted that the module division in this embodiment is illustrative and represents only a logical functional division. In actual implementation, other division methods may be used.
[0135] In the case of dividing each functional module into corresponding functional modules, the electronic device may include: an acquisition module, a construction module, a determination module, etc. It should be noted that all relevant contents of each step involved in the above method embodiment can be referred to the functional description of the corresponding functional module and will not be repeated here.
[0136] The electronic device provided in this embodiment is used to execute the above animation implementation method, and thus can achieve the same effect as the above implementation method.
[0137] In the case of an integrated unit, the electronic device may include a processing module and a storage module. The processing module may be used to control and manage the operation of the electronic device, and the storage module may be used to support the electronic device in executing relevant program codes and data.
[0138] The processing module may be a processor or controller that implements or executes the various exemplary logic blocks, modules, and circuits described in conjunction with the disclosure of this application. The processor may also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a digital signal processing (DSP) and a microprocessor, and the storage module may be a memory.
[0139] This embodiment further provides a computer-readable storage medium, in which computer program code is stored. When the computer program code is run on a computer, the computer executes the above-mentioned related method steps to implement an animation implementation method in the above-mentioned embodiment.
[0140] This embodiment further provides a computer program product. When the computer program product is run on a computer, the computer is caused to execute the above-mentioned related steps to implement an animation implementation method in the above-mentioned embodiment.
[0141] In addition, the electronic device provided in the embodiments of the present application can specifically be a chip, component or module, and the electronic device may include a connected processor and memory; wherein the memory is used to store instructions, and when the electronic device is running, the processor can call and execute instructions to enable the chip to execute an animation implementation method in the above embodiment.
[0142] Among them, the electronic device, computer-readable storage medium, computer program product or chip provided in this embodiment are all used to execute the corresponding methods provided above. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects in the corresponding methods provided above, and will not be repeated here.
[0143] In the embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely schematic. For example, the division of modules or units is only a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0144] The above content is merely a specific embodiment of the present application, but the scope of protection of the present application is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in this application should be included in the scope of protection of the present application. Therefore, the scope of protection of the present application should be based on the scope of protection of the claims.
Claims
1. A method for realizing animation, wherein: The method comprises: Get the animation type of the target animation; Construct the animation management object corresponding to the animation type through the animation management factory class; The target animation is determined based on the animation management object and the animation parameter information of the target animation.
2. The method according to claim 1, wherein: The step of constructing the animation management object corresponding to the animation type through the animation management factory class includes: Determine the animation management class corresponding to the animation type through the animation management factory class; The animation management class is instantiated through the animation management factory class to construct an animation management object corresponding to the animation management class.
3. The method according to claim 2, wherein: Before determining the animation management class corresponding to the animation type through the animation management factory class, the method includes: Encapsulate the animation management factory class, and define the animation management class corresponding to the animation type; The animation management factory class encapsulates a method for constructing an animation management object, and the animation management class defines an animation type and animation management properties corresponding to the animation type.
4. The method according to claim 2, wherein: The animation management classes corresponding to different animation types inherit from the same animation management base class.
5. The method according to claim 4, wherein: Before determining the animation management class corresponding to the animation type through the animation management factory class, the method further includes: Define the animation management base class; The animation management base class defines animation play logic and animation view acquisition method.
6. The method according to claim 1, wherein: The animation parameter information includes animation play control information and animation play content information.
7. The method according to claim 1, wherein: After determining the target animation based on the animation management object and the animation parameter information of the target animation, the method further includes: The view component carrying the target animation is output to the user interface layer for display.
8. An animation realization device, wherein: The device comprises: The acquisition module is used to obtain the animation type of the target animation; A construction module, used to construct an animation management object corresponding to the animation type through an animation management factory class; A determination module is used to determine the target animation based on the animation management object and the animation parameter information of the target animation.
9. An electronic device, wherein: The electronic device comprises: A memory for storing executable program codes; A processor, configured to call and run the executable program code from the memory, so that the electronic device executes the method according to any one of claims 1 to 7.
10. A computer-readable storage medium, wherein: The computer-readable storage medium stores a computer program, and when the computer program is executed, the method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Animation creation method and apparatus, electronic device and computer readable storage medium
CN108038894A
System control customized animation realization method and electronic device based on education system
CN109117234A
Animation playing method and device, equipment and medium
CN115496842A
Animation implementation method and device, electronic equipment and storage medium
CN117193720A
Device and Method for Dynamically Rendering an Animation
US20120306890A1
Cited By
Reusable animation control method based on behavior pattern
CN122064337A