Sequential frame animation playing method, device and storage medium

By generating a player object and adjusting the frame identifiers in conjunction with keyframe identifiers, the sequential frame playback method solves the problems of high resource consumption and keyframe skipping in the Animator component, achieving smoother and more stable sequential frame animation playback.

CN117710544BActive Publication Date: 2026-05-15XIAMEN WEIWO TIME TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
XIAMEN WEIWO TIME TECH CO LTD
Filing Date
2023-12-11
Publication Date
2026-05-15

AI Technical Summary

Technical Problem

In existing technologies, the Animator component suffers from high resource consumption, high learning costs, and keyframe skipping issues when playing sequence frame animations, leading to instability in game smoothness and business logic.

Method used

The sequential frame playback method is adopted to generate a player object. The identifier of the frame to be played is determined based on the reference playback duration and playback parameters, and the frame identifier is adjusted in combination with the key frame identifier. The player object is controlled to obtain frame information and execute playback logic. The serialization tool is used to parse and serialize the aeprite format file to generate a playback object that meets the playback requirements.

Benefits of technology

It improves the smoothness of sequence frame animation and the stability of project business logic, reduces resource consumption, lowers the learning cost, and avoids keyframe skipping and stuttering.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117710544B_ABST
    Figure CN117710544B_ABST
Patent Text Reader

Abstract

The application relates to the technical field of game development, and provides a sequence frame animation playing method, equipment and a storage medium. The sequence frame playing method comprises the following steps: in response to a playing request, generating a player object, determining a to-be-played frame identifier from frame information of the playing object based on a reference playing duration and playing parameters corresponding to the player object, and further determining whether a key frame identifier exists between the to-be-played frame identifier and a final playing frame identifier; in the case that the key frame identifier exists between the to-be-played frame identifier and the final playing frame identifier, the to-be-played frame identifier is re-determined in combination with the key frame identifier; and the player object is controlled to acquire frame information and execute playing logic with the re-determined to-be-played frame identifier as a parameter, so that the artistic performance and frame event calling of the key frame in the playing process can be avoided from being skipped, and the stable operation of project business logic can be ensured.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of game development, and in particular to the control of game sequence frame animation. Background Technology

[0002] In the animation implementation process of game development, in order to ensure the quality of the displayed image and the smoothness of the animation playback, frame sequence is usually used for animation playback.

[0003] In related technologies, the AnimationClip file is first created manually, and then the Animator component in the Unity engine is used to play the sequence frame animation in the AnimationClip file.

[0004] However, the Animator component has issues when accelerating the processing of AnimationClip files. For example, when the animation length is too short, some key animation frames will be skipped uncontrollably. This will cause the artwork and frame event calls of key animation frames to be skipped, which in turn will lead to instability in the operation of the project's business logic. Summary of the Invention

[0005] To help improve the stability of project business logic operation, this application provides a sequence frame playback method, device, and storage medium.

[0006] Firstly, this application provides a method for playing sequential frames, employing the following technical solution:

[0007] A method for playing a sequence of frames, the method comprising:

[0008] In response to a playback request, a player object is generated;

[0009] The identifier of the frame to be played is determined from the frame information of the playback object based on the reference playback duration and playback parameters corresponding to the playback object, which is preset.

[0010] Determine whether there is a keyframe identifier between the frame identifier to be played and the final playback frame identifier, wherein the final playback frame identifier is the identifier corresponding to the animation frame played by the player object last time;

[0011] If the keyframe identifier exists between the identifier of the frame to be played and the identifier of the final playback frame, the identifier of the frame to be played is re-determined in combination with the keyframe identifier.

[0012] The player object is controlled to obtain frame information and execute playback logic using the redefined identifier of the frame to be played as a parameter, and the final playback frame identifier is updated if playback is successful.

[0013] By adopting the above technical solution, when there is a keyframe identifier between the identifier of the frame to be played determined by combining the reference playback duration and the final playback frame identifier, the identifier of the frame to be played can be re-determined by combining the keyframe identifier, and the player object can be controlled to obtain frame information and execute playback logic with the re-determined identifier of the frame to be played as a parameter. This can help avoid the skipping of the artistic expression of keyframes and frame event calls during playback, and thus help ensure the stable operation of the project's business logic.

[0014] Optionally, after determining whether a keyframe identifier exists between the identifier of the frame to be played and the identifier of the final playback frame, the method further includes:

[0015] If there is no keyframe identifier between the identifier of the frame to be played and the identifier of the final playback frame, the player object is controlled to obtain frame information with the identifier of the frame to be played as a parameter and execute playback logic. If the playback is successful, the identifier of the final playback frame is updated.

[0016] By adopting the above technical solution, even when there is no keyframe identifier between the identifier of the frame to be played and the identifier of the final playback frame, the frame information can be obtained directly based on the identifier of the frame to be played determined based on the reference playback duration and playback parameters, without considering the frame skipping situation of other types of frames. This can help to play the playback object according to the reference playback duration.

[0017] Optionally, before determining the identifier of the frame to be played from the frame information of the playback object based on the reference playback duration and playback parameters corresponding to the player object, the method further includes:

[0018] The interval between the current time and the start playback time corresponding to the player object is determined as the reference duration, where the start playback time is recorded when the player object is generated.

[0019] By adopting the above technical solution, the playback progress of the playback object can be controlled by referring to the duration, which can help avoid the problem of large delays in the playback object caused by abnormal factors (such as stuttering) during the playback process, and thus help to match the determined frame to be played with the actual playback duration of the player object.

[0020] Optionally, the playback parameters include playback speed, and the step of determining the identifier of the frame to be played from the frame information of the playback object based on the reference playback duration and playback parameters corresponding to the player object includes:

[0021] Determine whether there is a speed change record corresponding to the playback speed, the speed change record including the change time point and the changed speed;

[0022] If the speed change record is confirmed, the current playback progress is determined by combining the reference playback duration, the change time point, and the changed speed.

[0023] The identifier of the frame to be played is determined from the frame information of the playback object based on the current playback progress.

[0024] By adopting the above technical solution, the correspondence between the playback duration and the frame identifier to be played can be adjusted according to the speed change, which can help improve the accuracy of the determined frame identifier to be played, and thus help improve the smoothness of animation playback.

[0025] Optionally, the method further includes:

[0026] In response to the playback object generation instruction, an initial object file is obtained, wherein the initial object file is in aeprite format;

[0027] The serialization tool parses and obtains the object data corresponding to the initial object file. The object data includes frame information, layer information, cell data, and keyframes (vitaFrame). The serialization tool is pre-set according to constraint rules.

[0028] The object data is serialized to obtain the playback object.

[0029] By adopting the above technical solution, the serialization tool can be used to deserialize and reserialize the initial object file in aeprite format according to the constraint rules based on the actual playback needs, and finally obtain the playback object that meets the playback requirements, which can help control the playback of sequence frame animation.

[0030] Optionally, the constraint rules include keyframe identification rules, and the step of parsing and obtaining the corresponding object data in the initial object file using a serialization tool includes:

[0031] The serialization tool parses the frame information (Frame) corresponding to each animation frame in the initial object file.

[0032] Based on the frame information, the animation frames that satisfy the keyframe identification rules are identified as the keyframes (vitaFrames).

[0033] Optionally, before generating the player object in response to a playback request, the method further includes:

[0034] Based on the layer information Layers, a layer playback node corresponding to the playback object is generated on the mounted object, and a rendering component is mounted on the layer playback node;

[0035] The step of generating a player object in response to a playback request includes:

[0036] In response to a playback request, determine whether the playback object exists;

[0037] If the existence of the playback object is determined, the player object is generated.

[0038] By adopting the above technical solution, upon receiving a playback request, it is possible to verify whether a playback object exists. Only if a playback object exists will the corresponding player object be generated. This helps to avoid the problem of a poor user experience caused by the inability to play a player object after it has been generated due to the absence of a playback object. In this way, it can help improve the user experience.

[0039] Optionally, the method further includes:

[0040] A base animation object is determined from the at least two initial animation objects, and the initial animation objects other than the base animation object are determined as supplementary animation objects, wherein the file format of the initial animation objects is the same as the file format of the playback object;

[0041] Determine whether there is a first target layer with the same color and name as the base animation object in each layer of the supplementary animation object. If so, replace the information of the first target layer in the base animation object with the information of the first target layer in the supplementary animation object.

[0042] Determine whether there is a second target layer in each layer of the supplementary animation object that has the same color as the base animation object but a different name. If so, merge the information of the second target layer in the supplementary animation object with the information of the second target layer in the base animation object.

[0043] The base animation object, after layer replacement and merging, is determined as the playback object.

[0044] By adopting the above technical solution, at least two initial layers can be mixed by replacement and merging based on the relationship between layer color and layer name to obtain the playback object. This can help realize the function of layer replacement playback, and thus help to flexibly adjust the playback mode of sequence frame animation.

[0045] Secondly, this application provides an electronic device that adopts the following technical solution:

[0046] An electronic device, the electronic device comprising:

[0047] At least one processor;

[0048] Memory;

[0049] At least one application, wherein the at least one application is stored in memory and configured to be executed by at least one processor, the at least one application being configured to: execute any of the sequence frame playback methods provided in the first aspect.

[0050] Thirdly, this application provides an electronic device that adopts the following technical solution:

[0051] A computer-readable storage medium having a computer program stored thereon, which, when executed in a computer, causes the computer to perform any of the sequence frame playback methods provided in the first aspect.

[0052] In summary, this application includes at least one of the following beneficial technical effects:

[0053] 1. If there is a keyframe identifier between the identifier of the frame to be played determined by combining the reference playback duration and the final playback frame identifier, the identifier of the frame to be played can be re-determined by combining the keyframe identifier. The player object can then use the re-determined identifier of the frame to be played as a parameter to obtain frame information and execute playback logic. This can help avoid the skipping of keyframe art and frame event calls during playback, thereby helping to ensure the stable operation of the project's business logic.

[0054] 2. According to the actual playback needs, the serialization tool can be used to deserialize and reserialize the initial object file in aeprite format according to the constraint rules, and finally obtain the playback object that meets the playback requirements, which can help control the playback of the sequence frame animation. Attached Figure Description

[0055] Figure 1 This is a flowchart illustrating a sequence frame playback method provided in an embodiment of this application;

[0056] Figure 2 This is a flowchart illustrating a playback object generation method provided in an embodiment of this application;

[0057] Figure 3 This is a schematic diagram of a constraint tag adding page provided in an embodiment of this application;

[0058] Figure 4 This is a schematic diagram illustrating an example of a playback object provided in an embodiment of this application;

[0059] Figure 5This is a flowchart illustrating a method for generating a player object according to an embodiment of this application;

[0060] Figure 6 This is a flowchart illustrating an animation object blending method provided in an embodiment of this application;

[0061] Figure 7 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation

[0062] To make the purpose, technical solution, and advantages of this application clearer, the following description is provided in conjunction with the appendix. Figure 1-7 The present application will be further described in detail below with reference to embodiments. It should be understood that the specific embodiments described herein are for illustrative purposes only and are not intended to limit the scope of the application.

[0063] In related technologies, the generation and playback of sequence frame animations include the following two methods:

[0064] The first method involves manually creating AnimationClip files to achieve sequential frame animation playback, which includes the following steps:

[0065] Step 1: Import the pixel sequence frame group into the Unity project. Typically, the pixel sequence frame group consists of a series of image files (usually in PNG or JPEG format).

[0066] Create a new animation object in Unity and add an Animator component to it.

[0067] Step 2: Record the switching of the sequence frame group and the mounting frame event in the Animator's recording interface, and finally generate the sequence frame animation (type AnimationClip).

[0068] Step 3: Use the Animator component to sequence frame animations during project execution.

[0069] During implementation, it was found that the above solution has problems such as difficulty in previewing when there are many images in the sequence frame image group and when it is necessary to modify a certain image, and loss of frame animation due to changes in the sequence frame image ID after import, which affects work efficiency.

[0070] The second method is to use asesprite-importer to play sequence frame animations.

[0071] Step 1: Use the pixel art drawing software Aseprite to draw a set of pixel sequence frame animations and export the aseprite file.

[0072] Step 2: Place asesrite in the project directory.

[0073] Step 3: Use the aeprite-importer plugin to reimport aeprite in the Unity project, and generate a sequence frame animation (of type AnimationClip) containing sequence frame information in the specified path.

[0074] Step 4: Use the Animator component to play the sequence frame animation during project execution.

[0075] However, the above solutions all rely on the Animator component in the Unity engine to play the sequence frames during project operation. While Animator is powerful, it still has the following problems.

[0076] First, for the need to play pixel sequence frames, the Animator component is not lightweight enough. During operation, AnimationClip needs to go through AnimationMixer and AnimationLayerMixer to finally output to AnimationController for playback, which will consume certain resources. Especially on mobile devices, this will lead to a decrease in device performance and affect the smoothness of games or applications.

[0077] Secondly, the Animator component uses a state machine to control the switching of AnimatorState, and obtaining StateInfo has a certain lag. The complex animation state machine will also increase the learning cost for users to get started with the project.

[0078] Third, there is a problem with Animator's acceleration of AnimationClip. When the duration is too short, it will uncontrollably skip some key animation frames, causing frame events to not respond or the animation performance to not meet expectations.

[0079] This application discloses a method for playing sequential frames. (Refer to...) Figure 1 The sequence frame playback method includes the following steps:

[0080] Step 101: In response to the playback request, generate a player object.

[0081] The playback request is used to indicate the start of playback of the sequence frame animation. Specifically, the playback request can be generated in response to user operation, such as when the user triggers the "play" control, or it can be automatically generated according to preset rules, such as when the user enters a specific game scene or when a game monster appears. This embodiment does not limit the way the playback request is generated.

[0082] The player object is used to play a sequence of animated frames. In one example, the player object is a `playInstance` object. Because the `playInstance` interface can generate a `playInstance` object simultaneously with a playback request, unlike `Animator` which requires a delay to obtain `StateInfo` from the state machine, this helps to improve the response speed of playback requests.

[0083] Furthermore, the player object includes interfaces such as StartTime, Duration, and Speed, which can be dynamically controlled. The StartTime interface records the start time of playback, and the Speed ​​interface adjusts the playback speed.

[0084] Step 102: Determine the identifier of the frame to be played from the frame information of the playback object based on the reference playback duration and playback parameters corresponding to the player object.

[0085] The reference playback duration is used to determine the playback progress of the playback object.

[0086] Playback parameters are used to determine how an object is played. For example, playback parameters include playback speed and refresh rate.

[0087] The playback object is pre-defined and includes a sequence of animated frames. Specifically, the playback object consists of several animation frames, each with a unique frame identifier. In one instance, the frame identifier for each animation frame is set based on the time point of the animation frame within the sequence of animated frames. This helps to identify the playback order relationship between the various animation frames based on the frame identifier.

[0088] The CurrentFrameIndex is the identifier of the animation frame that is currently expected to be played.

[0089] In one example, before determining the playable identifier from the frame information of the playback object based on the reference playback duration and playback parameters corresponding to the player object, the method further includes: determining the interval between the current time and the start playback time corresponding to the player object as the reference duration.

[0090] The start playback time is recorded when the player object is generated.

[0091] Accordingly, playback parameters include playback speed. The playback identifier is determined from the frame information of the playback object based on the reference playback duration and playback parameters corresponding to the player object, including: determining the current playback progress based on the reference playback duration and playback speed corresponding to the player object; and determining the playback identifier from the frame information of the playback object based on the current playback progress.

[0092] The playback speed is used to indicate the relationship between the reference playback duration and the playback progress. In practice, the playback speed can be set according to actual needs. In one example, the system provides playback speed adjustment controls, allowing the playback speed to be adjusted as needed.

[0093] In the above technical solution, since the reference duration is the cumulative playback duration corresponding to the player object, the playback progress determined based on the reference duration is the cumulative playback progress. This can help control the playback progress of the playback object through the reference duration, thereby helping to avoid the problem of large delays in the playback of the playback object caused by abnormal factors (such as stuttering) during the playback process. In turn, it can help to match the determined frame to be played with the actual playback duration of the player object.

[0094] Furthermore, during animation playback, the playback speed is adjustable. At this time, the current playback progress is determined based on the reference playback duration and playback speed corresponding to the player object, including: determining whether there is a speed change record corresponding to the playback speed, the speed change record including the change time point and the changed speed; if a speed change record is determined to exist, the current playback progress is determined by combining the reference playback duration, the change time point, and the changed speed; if no speed change record is determined to exist, the current playback progress is determined based on the reference playback duration and playback speed.

[0095] The speed change record is generated when the playback speed changes. For example, if the playback speed is adjusted from "×1" to "×1.5" at the first moment, a speed change record will be generated with the change time being the first moment and the playback speed after the change being "×1.5".

[0096] In one instance, the current playback progress is determined by combining the reference playback duration, the change time point, and the changed speed, including: determining the reference duration corresponding to the most recent change time point as the change point playback duration; determining the difference between the reference playback duration and the change point playback duration as the changed duration; and determining the current playback progress by combining the playback progress corresponding to the change time point, the changed duration, and the changed speed.

[0097] In the above technical solution, since the current playback progress and the identifier of the frame to be played can be determined by combining the change time point and the changed speed recorded in the speed change record when there is a speed change record, the correspondence between the playback duration and the identifier of the frame to be played can be adjusted according to the speed change situation, which can help improve the accuracy of the identified identifier of the frame to be played, and thus help improve the smoothness of animation playback.

[0098] In another example, before determining the playable identifier from the frame information of the playback object based on the reference playback duration and playback parameters corresponding to the player object, the method further includes: determining the interval between the current time and the time of the last playback of the animation frame of the player object as the reference duration.

[0099] Accordingly, the playback parameters include playback speed, and the identification of the frame to be played is determined from the frame information of the playback object based on the reference playback duration and playback parameters corresponding to the player object. This includes: determining the identification of the frame to be played from the frame information of the playback object based on the frame identification of the animation frame played last time by the player object, the reference playback duration, and playback parameters.

[0100] Step 103: Determine whether there is a keyframe identifier between the identifier of the frame to be played and the identifier of the final playback frame.

[0101] The LastFrameIndex is the identifier corresponding to the last animation frame played by the player object.

[0102] The keyframe identifier (vitaFrameIndex) is used to identify keyframes in the playback object. A keyframe is an animation frame with a key effect. The keyframe identifier in the playback object is set in advance.

[0103] Since there may be frame skipping during the playback of a sequence frame animation, and skipping some key frames may cause some key events to not respond or the animation performance to not meet expectations, this embodiment verifies the frame to be played by checking whether there is a key frame identifier between the identifier of the frame to be played and the identifier of the final playback frame.

[0104] In one example, an animation sequence has three frames: raising the sword, swinging the sword, and sheathing the sword. When playing in a high-speed loop, the player may only see the sword raised or sheathed, while the swing is skipped from time to time. In this case, setting the swing as a keyframe can ensure that the player can always see the corresponding visual effects of the swing.

[0105] In frame-by-frame animation, the animation frames are usually arranged in a certain order, including regular frames and keyframes. Generally, keyframes and regular frames are spaced apart.

[0106] In practice, each animation frame includes a frame identifier, and the frame identifier is related to the order in which the animation frames are arranged. This allows the order of the animation frames to be determined based on the frame identifiers. For example, the frame identifiers can be set sequentially according to the order in which the animation frames are sorted.

[0107] In one example, the playback object includes five frames identified as 12, 13, 14, 15, and 16, where 13 is a keyframe. Thus, if the frame to be played is identified as 16, and the final playback frame is identified as 12, it is determined that there is a keyframe identifier between the frame to be played and the final playback frame. If the final playback frame is identified as 13, 14, or 15, it is determined that there is no keyframe identifier between the frame to be played and the final playback frame.

[0108] Step 104: If there is a keyframe identifier between the frame to be played and the final frame to be played, the frame to be played is re-determined by combining the keyframe identifier.

[0109] In one example, the keyframe identifier is combined with the keyframe identifier to redetermine the identifier to be played, including: determining the keyframe identifier between the identifier to be played and the final playback frame identifier as the identifier to be played.

[0110] Furthermore, when there are two or more keyframes between the target frame identifier and the final playback frame identifier, the keyframe identifier between the target frame identifier and the final playback frame identifier is determined as the target frame identifier. This includes determining the first keyframe identifier in the sequence among the keyframe identifiers between the target frame identifier and the final playback frame identifier as the target frame identifier. This can help to further avoid skipping keyframes.

[0111] In another example, the identifier for the frame to be played is redefined by combining the keyframe identifier with the identifier for the frame to be played. This includes determining whether the final playback frame identifier is the same as the previous frame identifier of the keyframe identifier; if they are the same, the keyframe identifier is determined as the identifier for the frame to be played; if they are different, the previous frame identifier of the keyframe identifier is determined as the identifier for the frame to be played. This helps to ensure the smoothness of keyframe playback.

[0112] Step 105: Control the player object to obtain frame information and execute playback logic with the redefined frame identifier to be played as a parameter, and update the final playback frame identifier if playback is successful.

[0113] Each frame information corresponds one-to-one with a frame identifier, and the frame information is preset in the playback object. In one example, the frame information includes frame animations and / or frame events.

[0114] Optionally, the control player object obtains frame information and executes playback logic with the redefined identifier of the frame to be played as a parameter, including: determining the frame information corresponding to the redefined identifier of the frame to be played as the frame information to be played; and executing playback logic based on the frame information to be played.

[0115] In one example, playback information is executed based on the information of the frame to be played, including: retrieving the corresponding rendering parameters based on the layer image identifier in the information of the frame to be played and configuring them on the rendering component; checking whether there is event call data in the information of the frame to be played, and if so, performing a callback based on the event data, thereby realizing frame animation switching and frame event calling.

[0116] In one instance, the rendering component is implemented using the SproutRenender component in Unity, and the corresponding rendering parameter is Sprite.

[0117] Optionally, after determining whether there is a keyframe identifier between the frame identifier to be played and the final playback frame identifier, the method further includes: if there is no keyframe identifier between the frame identifier to be played and the final playback frame identifier, controlling the player object to obtain frame information with the frame identifier to be played as a parameter and execute playback logic, and updating the final playback frame identifier if playback is successful (step 106).

[0118] Since there is no keyframe identifier between the frame to be played and the final frame to be played, the frame skipping of other types of frames is not considered. Instead, the frame information is obtained directly based on the frame to be played determined based on the reference playback duration and playback parameters, and the playback logic is executed. This can help to play the playback object according to the reference playback duration.

[0119] Optionally, if playback is successful, return to step 102. This allows for continuous playback of the sequence frame animation.

[0120] The implementation principle of a sequence frame playback method according to an embodiment of this application is as follows: In response to a playback request, a player object is generated; based on the reference playback duration and playback parameters corresponding to the player object, the identifier of the frame to be played is determined from the frame information of the playback object, which is preset in advance; it is determined whether there is a keyframe identifier between the identifier of the frame to be played and the final playback frame identifier, wherein the final playback frame identifier is the identifier corresponding to the animation frame played by the player object last time; if there is a keyframe identifier between the identifier of the frame to be played and the final playback frame identifier, the identifier of the frame to be played is re-determined in combination with the keyframe identifier; the player object is controlled to obtain frame information and execute playback logic with the re-determined identifier of the frame to be played as a parameter, and the final playback frame identifier is updated if playback is successful. In the above technical solution, after determining the identifier of the frame to be played by combining the reference playback duration, it is further determined whether there is a key frame identifier between the identifier of the frame to be played and the final playback frame identifier. If there is a key frame identifier between the identifier of the frame to be played and the final playback frame identifier, the identifier of the frame to be played is re-determined by combining the key frame identifier. The player object is then controlled to obtain frame information and execute playback logic with the re-determined identifier of the frame to be played as a parameter. This helps to avoid the skipping of the artistic expression of key frames and frame event calls during playback, thereby helping to ensure the stable operation of the project's business logic.

[0121] In addition, since it is possible to determine whether a keyframe has been skipped based on the presence of a keyframe identifier between the identifier of the frame to be played and the identifier of the final played frame, without having to examine the specific frame content, this can help improve the efficiency of the judgment and also help reduce the amount of computation in the judgment process.

[0122] In addition, since the most recently played animation frame is marked by the final playback frame identifier, it is possible to determine whether a keyframe has been skipped based on the relationship between the determined to-be-played frame identifier and the final playback frame identifier, without having to track whether each keyframe is executed. This makes it easier to determine whether a keyframe has been skipped.

[0123] In some implementations, reference Figure 2 The sequence frame animation playback method provided in this embodiment further includes the following steps:

[0124] Step 201: In response to the playback object generation instruction, obtain the initial object file.

[0125] The initial object file is in Aseprite format. Specifically, by using the pixel art drawing software Aseprite to draw a series of pixel sequence frames, the initial object file in Aseprite format can be exported.

[0126] In related technologies, for aeprite files, during playback, the aeprite-importer plugin is first used to reimport the aeprite file in the Unity project, generating an AnimationClip containing sequence frame information in a specified path. Then, the Animator component is used to play the recorded sequence frame animation. However, as mentioned earlier, the Animator component has many problems in playing AnimationClip. Therefore, this embodiment proposes a new method for generating sequence frame animation files to generate sequence frame animations suitable for the above-mentioned sequence frame animation playback method.

[0127] Optionally, after obtaining the initial object file, the process also includes importing the initial object file into the Unity project. This facilitates manipulation of the initial object file.

[0128] Step 202: Use a serialization tool to parse and obtain the object data corresponding to the initial object file.

[0129] The serialization tool is pre-configured according to constraint rules. Specifically, it is used to deserialize the initial object file to obtain the object data.

[0130] The object data includes frame information, layer information, cell data, and keyframes (vitaFrame). Specifically, frame information is typically used to read frame duration, sequence frame image information, frame event information, etc.; cell data is used to indicate cell data in the aspirite. In actual implementation, other data may also be included, such as user configuration data (UserData) reserved in the cells of the aspirite file.

[0131] Optionally, the constraint rules include keyframe identification rules, which are obtained by parsing the corresponding object data in the initial object file through a serialization tool. This includes: parsing the frame information (Frame) corresponding to each animation frame in the initial object file through a serialization tool; and determining the animation frames that satisfy the keyframe identification rules in each animation frame as keyframes (vitaFrame) based on the frame information (Frame).

[0132] In one example, based on Frame Information Detection, animation frames that meet the keyframe identification rules are identified as keyframes, including: based on Frame Information Detection, animation frames that contain constraint identifiers corresponding to keyframes are identified as keyframes.

[0133] Among them, constraint markers are added by staff (such as artists) based on keyframe marker rules during the initial object file creation process. That is, the constraint markers corresponding to keyframes correspond to the keyframe marker rules. For example, if the keyframe marker is to highlight the animation frame in red, then the animation frame highlighted in red will be identified as a keyframe during the parsing process.

[0134] In one instance, refer to Figure 3 , Figure 3 Add pages for constraint marking rules, for example: the position corresponding to legr in frame 17 is marked in red, which means that frame 17 is a keyframe.

[0135] In practice, serialization tools can also include other constraint rules, such as splitting animation clips by tags and grouping layers by configuring different colors in the layer information. Correspondingly, during the initial object file creation process, staff can add corresponding constraint identifiers according to the constraint rules. During the parsing process, the serialization tool can also restore the corresponding constraint identifiers based on the constraint rules, thereby parsing out the corresponding constraint conditions.

[0136] In one example, the object data corresponding to the initial object file is obtained by parsing the serialization tool. Before that, it also includes: writing a serialization utility class according to the constraint rules and overloading the AssetImporters.ScriptedImporter.OnImportAsset interface under the UnityEditor namespace.

[0137] Accordingly, the object data corresponding to the initial object file is obtained by parsing the serialization tool, including: calling System.IO.FileSteram to read the initial file under the path, parsing the initial object file with the serialization tool, and obtaining the object data in the initial object file.

[0138] Step 203: Serialize the object data to obtain the playback object.

[0139] Optionally, the object data can be serialized to obtain the playback object, including: using a serialization tool to serialize frame information (Frame), layer information (Layers), cell data (Chunk), and keyframes (vitaFrame) to obtain the playback object.

[0140] In one instance, refer to Figure 4 , Figure 4 For a playback object (i.e.) Figure 4 A diagram of a VeewoAnim instance.

[0141] In one example, serializing object data includes using a serialization tool to serialize the object data to obtain a playback object.

[0142] In one instance, the serialization tool is used to serialize the object data to obtain the playback object, including: calling the AddOnjectToAsset interface under the UnityEditor.AssetImporters.AssetImportContext namespace to create the playback file storage object data and instantiate it into the project.

[0143] In the above embodiments, since the initial object file can be parsed by a serialization tool based on pre-set constraint rules to obtain the object data corresponding to the initial object file, and the parsed object data can be re-serialized to obtain the playback object, the initial object file in aeprite format can be automatically converted into a playback object according to the actual playback needs, which can help control the playback of the sequence frame animation.

[0144] Further reference Figure 5 Step 101, before generating the player object in response to a playback request, also includes:

[0145] Step 301: Based on the layer information, generate the layer playback node corresponding to the playback object in the mounted object, and mount the rendering component on the layer playback node.

[0146] The rendering component is used to render the animated characters. In one example, the rendering component is the SpritterRenender component.

[0147] Accordingly, step 101, in response to the playback request, generates a player object, including the following steps:

[0148] Step 302: In response to the playback request, determine whether a playback object exists.

[0149] Optionally, determining whether a playback object exists includes: determining whether the mounted object has a layer playback node; if it exists, then determining that a playback object exists; if it does not exist, then determining that no playback object exists.

[0150] Step 303: If a playback object is determined to exist, a player object is generated.

[0151] Optionally, if it is determined that there is no playback object, the process is terminated and no player object is generated.

[0152] In the above technical solution, when a playback request is received, the existence of a playback object is checked. Only when a playback object exists is the corresponding player object generated. This helps to avoid the problem of the player object being unable to play due to the absence of a playback object after it has been generated, which leads to a poor user experience. In this way, it can help to improve the user experience.

[0153] In some implementations, reference Figure 6 The frame sequence animation playback method provided in this embodiment further includes the following steps:

[0154] Step 401: Determine the base animation object from at least two initial animation objects, and determine the initial animation objects other than the base animation object as supplementary animation objects.

[0155] The file format of the initial animation object is the same as that of the playback object.

[0156] Optionally, the base animation object is determined from the initial animation objects, including: determining the base animation object from the initial animation objects that contain the base animation identifier.

[0157] In actual implementation, the basic animation object can also be determined in other ways. For example, the first initial animation object read among the various initial animation objects is determined as the basic animation object. This embodiment does not limit the way the basic animation object is determined.

[0158] Step 402: Determine whether there is a first target layer with the same color and name as the base animation object in each layer of the supplementary animation object. If so, replace the information of the first target layer in the base animation object with the information of the first target layer in the supplementary animation object.

[0159] In this example, the color and name of the layers in the initial animation object are set during the initial animation generation process. Specifically, the initial animation object is generated in the same way as the playback object, as described in steps 201 to 203, which will not be repeated here. In one example, the image color is used to identify layer groups; for example, different groups correspond to different layer colors.

[0160] Optionally, the colors and names of layers in the initial animation are generated during the parsing and serialization of the initial object file using a serialization tool. That is, the colors and names of layers are generated according to pre-set constraint rules. This makes it easier to standardize the colors and names of layers through constraint rules, thereby facilitating the matching of the layers in the supplementary animation object with the image of the basic animation object through color and name. This helps to achieve the fusion of elements of the same layer between different initial animation objects.

[0161] Step 403: Determine whether there is a second target layer in each layer of the supplementary animation object that has the same color as the base animation object but a different name. If so, merge the information of the second target layer in the supplementary animation object with the information of the second target layer in the base animation object.

[0162] In one example, merging the information of the second target layer in the supplementary animation with the information of the second target layer in the base animation object includes: overlaying the information of the second target layer in the supplementary animation with the information of the second target layer in the base second layer.

[0163] Step 404: Determine the base animation object after layer replacement and merging as the playback object.

[0164] In the above embodiments, since at least two initial layers can be mixed by replacement and merging based on the relationship between layer color and layer name to obtain the playback object, this can help realize the function of layer replacement playback, and thus help realize flexible adjustment of the playback mode of sequence frame animation.

[0165] This application also provides an electronic device. For example... Figure 7 As shown, Figure 7 The illustrated electronic device 500 includes a processor 501 and a memory 503. The processor 501 and the memory 503 are connected, for example, via a bus 502. Optionally, the electronic device 500 may also include a transceiver 504. It should be noted that in practical applications, the transceiver 504 is not limited to one type, and the structure of this electronic device 500 does not constitute a limitation on the embodiments of this application.

[0166] Processor 501 may be a CPU (Central Processing Unit), a general-purpose processor, a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. It may implement or execute the various exemplary logic blocks, modules, and circuits described in conjunction with the disclosure of this application. Processor 501 may also be a combination that implements computational functions, such as including one or more microprocessor combinations, a combination of a DSP and a microprocessor, etc.

[0167] Bus 502 may include a pathway for transmitting information between the aforementioned components. Bus 502 may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus, etc. Bus 502 can be divided into address bus, data bus, etc. For ease of representation, Figure 7 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.

[0168] The memory 503 may be ROM (Read Only Memory) or other types of static storage devices capable of storing static information and instructions, RAM (Random Access Memory) or other types of dynamic storage devices capable of storing information and instructions, or EEPROM (Electrically Erasable Programmable Read Only Memory), disk storage media or other magnetic storage devices, or any other medium capable of carrying or storing desired program code in the form of instructions or data structures and accessible by a computer, but is not limited thereto.

[0169] The memory 503 is used to store application code that executes the solution of this application, and its execution is controlled by the processor 501. The processor 501 is used to execute the application code stored in the memory 503 to implement the content shown in the foregoing method embodiments.

[0170] Electronic devices include, but are not limited to: mobile terminals such as mobile phones, laptops, PDAs (personal digital assistants), and PADs (tablet computers), as well as fixed terminals such as digital TVs and desktop computers. They can also serve as server-side components. Figure 7 The electronic device shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments of this application.

[0171] This application also provides a computer-readable storage medium storing a computer program thereon, which, when executed in a computer, causes the computer to execute the sequence frame playback method provided in the above embodiments.

[0172] It should be understood that although the steps in the flowcharts in the accompanying drawings are shown sequentially as indicated by the arrows, these steps are not necessarily performed in the order indicated by the arrows. Unless otherwise expressly stated herein, there is no strict order in which these steps are performed, and they may be performed in other orders.

[0173] The above are only some embodiments of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of this application, and these improvements and modifications should also be considered within the scope of protection of this application.

Claims

1. A method for playing a sequence of frames, characterized in that, The method includes: In response to a playback request, a player object is generated; Based on the reference playback duration and playback parameters corresponding to the player object, the identifier of the frame to be played is determined from the frame information of the playback object. The playback parameters are used to determine the playback mode of the playback object, and the playback parameters include the playback speed. During the animation playback, the playback speed is adjustable. The playback object is preset and includes a sequence of frame animations. Determine whether there is a keyframe identifier between the frame to be played identifier and the final playback frame identifier. The frame to be played identifier is the identifier of the animation frame currently expected to be played. The final playback frame identifier is the identifier corresponding to the animation frame played by the player object last time. If the keyframe identifier exists between the identifier of the frame to be played and the identifier of the final playback frame, the identifier of the frame to be played is re-determined in combination with the keyframe identifier. The player object is controlled to obtain frame information and execute playback logic using the redefined identifier of the frame to be played as a parameter, and the final playback frame identifier is updated if playback is successful. The methods for generating the playback object include: In response to the playback object generation instruction, an initial object file is obtained, wherein the initial object file is in aeprite format; The initial object file is deserialized using a serialization tool to obtain corresponding object data. This object data includes frame information (Frame), layer information (Layers), cell data (Chunk), and keyframes (vitaFrame). The serialization tool is pre-set according to constraint rules, including keyframe identification rules. The process of parsing and obtaining the corresponding object data from the initial object file using the serialization tool includes: parsing the frame information (Frame) corresponding to each animation frame in the initial object file using the serialization tool; and identifying the animation frames that satisfy the keyframe identification rules as the keyframes (vitaFrame) based on the frame information (Frame). The object data is serialized to obtain the playback object; Before obtaining the object data corresponding to the initial object file through the serialization tool, the process also includes: writing a serialization utility class according to the constraint rules and overloading the AssetImporters.ScriptedImporter.OnImportAsset interface under the UnityEditor namespace; The step of parsing and obtaining the object data corresponding to the initial object file through a serialization tool includes: calling System.IO.FileSteram to read the initial file under the path, parsing the initial object file through a serialization tool, and obtaining the object data in the initial object file; Use a serialization tool to serialize the object data to obtain the playback object, including: calling the AddOnjectToAsset interface under the UnityEditor.AssetImporters.AssetImportContext namespace to create the playback file, store the object data, and instantiate it in the project.

2. The method according to claim 1, characterized in that, After determining whether a keyframe identifier exists between the identifier of the frame to be played and the identifier of the final playback frame, the method further includes: If there is no keyframe identifier between the identifier of the frame to be played and the identifier of the final playback frame, the player object is controlled to obtain frame information with the identifier of the frame to be played as a parameter and execute playback logic. If the playback is successful, the identifier of the final playback frame is updated.

3. The method according to claim 1, characterized in that, Before determining the identifier of the frame to be played from the frame information of the playback object based on the reference playback duration and playback parameters corresponding to the player object, the method further includes: The interval between the current time and the start playback time corresponding to the player object is determined as the reference playback duration, where the start playback time is recorded when the player object is generated.

4. The method according to claim 3, characterized in that, The playback parameters include playback speed. The step of determining the frame identifier to be played from the frame information of the playback object based on the reference playback duration and playback parameters corresponding to the player object includes: Determine whether there is a speed change record corresponding to the playback speed, the speed change record including the change time point and the changed speed; If the speed change record is confirmed, the current playback progress is determined by combining the reference playback duration, the change time point, and the changed speed. The identifier of the frame to be played is determined from the frame information of the playback object based on the current playback progress.

5. The method according to claim 1, characterized in that, Before generating a player object in response to a playback request, the process also includes: Based on the layer information Layers, a layer playback node corresponding to the playback object is generated on the mounted object, and a rendering component is mounted on the layer playback node; The step of generating a player object in response to a playback request includes: In response to a playback request, determine whether the playback object exists; If the existence of the playback object is determined, the player object is generated.

6. The method according to claim 1, characterized in that, The method further includes: A base animation object is determined from at least two initial animation objects, and the initial animation objects other than the base animation object are determined as supplementary animation objects, wherein the file format of the initial animation objects is the same as the file format of the playback object; Determine whether there is a first target layer with the same color and name as the base animation object in each layer of the supplementary animation object. If so, replace the information of the first target layer in the base animation object with the information of the first target layer in the supplementary animation object. Determine whether there is a second target layer in each layer of the supplementary animation object that has the same color as the base animation object but a different name. If so, merge the information of the second target layer in the supplementary animation object with the information of the second target layer in the base animation object. The base animation object, after layer replacement and merging, is determined as the playback object.

7. An electronic device, characterized in that, The electronic device includes: At least one processor; Memory; At least one application, wherein the at least one application is stored in memory and configured to be executed by at least one processor, said at least one application being configured to: perform the sequence frame playback method according to any one of claims 1 to 6.

8. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed in the computer, the computer is instructed to perform the sequence frame playback method according to any one of claims 1 to 6.