Screen refresh method, device, electronic device and readable storage medium

By creating combat logic threads and virtual machines, multi -threaded collaboration of game screen refresh, solving the problem of improving the operating efficiency of game operation in existing technologies, but difficult to achieve hot updates, and enhance the user experience.

CN114691301BActive Publication Date: 2025-01-28BEIJING ZITIAO NETWORK TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210379054.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-12
Publication Date
2025-01-28
Estimated Expiration
2042-04-12

AI Technical Summary

Technical Problem

While the existing technology improves the efficiency of game operation, it is difficult to achieve hot updates, which limits the improvement of user experience.

Method used

Create combat logic threads and virtual machines by responding to target events, use combat logic threads to run combat logic and serialize logic frames. The main thread is obtained from the message queue and refresh the screen to support hot updates.

Benefits of technology

While improving the operating efficiency of the game, it supports hot updates and improves the user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114691301B_ABST
    Figure CN114691301B_ABST
Patent Text Reader

Abstract

The present disclosure provides a screen refresh method, device, electronic device and storage medium, the screen refresh method comprising: in response to a first target event being triggered, creating a battle logic thread, and creating a virtual machine based on the battle logic thread; wherein the virtual machine is used to run a script language file, and the battle logic thread is used to run the battle logic to obtain a logic frame; the logic frame is serialized by the battle logic thread, and the serialized logic frame is sent to the message queue of the main thread; the serialized logic frame is obtained from the message queue of the main thread, and based on the serialized logic frame, the current screen of the first target event is refreshed by the main thread. The embodiment of the present application can realize hot update while improving the running efficiency of the game.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technology, and in particular to a screen refresh method, a screen refresh device, an electronic device, and a storage medium. Background Art

[0002] With the increasing number of CPU (Central Processing Unit) cores, multi-threaded development and application has become an indispensable and important software technology. The use of multi-threaded concurrent execution mechanism can significantly improve the operating efficiency of the software. Especially in the field of game development, in order to provide players with a better user experience and achieve smooth game operation, a multi-threaded mechanism is usually adopted. However, although this solution can improve the smoothness of game operation, it cannot achieve hot updates. Summary of the invention

[0003] The embodiments of the present disclosure at least provide a screen refresh method, device, electronic device and storage medium, which can improve the game running efficiency while realizing hot update.

[0004] The present disclosure provides a screen refresh method, including:

[0005] In response to the first target event being triggered, a battle logic thread is created, and a virtual machine is created based on the battle logic thread; wherein the virtual machine is used to run a script language file, and the battle logic thread is used to run a battle logic to obtain a logic frame;

[0006] The logic frame is serialized through the battle logic thread, and the serialized logic frame is sent to the message queue of the main thread;

[0007] The serialized logical frame is obtained from the message queue of the main thread, and based on the serialized logical frame, the current screen of the first target event is refreshed through the main thread.

[0008] In the disclosed embodiment, in response to the first target event being triggered, a battle logic thread is created, so that the battle logic is run through the logic thread and the screen is refreshed through the main thread, that is, multiple threads are run simultaneously, thereby improving the running efficiency of the game. In addition, a virtual machine is created based on the battle logic thread, and the virtual machine is used to run the script language file, thereby supporting hot updates and improving the user experience.

[0009] In a possible implementation, refreshing the current screen of the first target event through the main thread based on the serialized logical frame includes:

[0010] Based on a preset serialization access protocol, obtaining the content of the serialized logical frame;

[0011] Based on the content of the serialized logical frame, the current screen of the first target event is refreshed through the main thread.

[0012] In the disclosed embodiment, the content of the serialized logical frame is obtained based on a preset serialization access protocol, and thus the serialized content does not need to be deserialized before being displayed. This reduces the time of the deserialization process and further improves the running efficiency of the game.

[0013] In a possible implementation, the method further includes:

[0014] Based on the display frame rate of the current screen of the first target event, determining a first target frame number through the main thread, and sending the first target frame number to the battle logic thread;

[0015] The step of serializing the logic frame through the battle logic thread and sending the serialized logic frame to the message queue of the main thread includes:

[0016] Serializing the first target logic frame corresponding to the first target frame number through the battle logic thread, and sending the serialized target logic frame to the message queue of the main thread;

[0017] The acquiring the serialized logical frame from the message queue of the main thread, and refreshing the current screen of the first target event through the main thread based on the serialized logical frame, includes:

[0018] The serialized first target logical frame is obtained from the message queue of the main thread, and based on the serialized first target logical frame, the current screen of the first target event is refreshed through the main thread.

[0019] In the disclosed embodiment, the main thread can dynamically predict the first target frame number and send the first target frame number to the combat logic thread, so that the combat logic thread only needs to return the first target logic frame corresponding to the first target frame number. In this way, the information that needs to be interacted between the main thread and the combat logic thread can be reduced, further improving the game operation efficiency.

[0020] In a possible implementation, the method further includes:

[0021] In a case where a trigger operation for a second target event is detected, determining a second target frame number through the main thread, the second target frame number being greater than the first target frame number;

[0022] Sending the second target frame number to the battle logic thread through the main thread;

[0023] Serializing the second target logic frame corresponding to the second target frame number through the battle logic thread, and sending the serialized second target logic frame to the message queue of the main thread;

[0024] The serialized second target logical frame is obtained from the message queue of the main thread, and based on the serialized second target logical frame, the current screen of the second target event is refreshed through the main thread.

[0025] In the disclosed embodiment, when a trigger operation for a second target event is detected, the main thread sends the second target frame number to the combat logic thread, and the second target frame number is greater than the first target frame number. In this way, the game operation efficiency can be further improved in some scenarios (player operations) without affecting the screen display.

[0026] In a possible implementation, serializing the logic frame through the battle logic thread and sending the serialized logic frame to the message queue of the main thread includes:

[0027] Determine the current running speed of the first target event through the battle logic thread;

[0028] When the current running speed is 1x, the first target logic frame corresponding to the first target frame number is serialized through the battle logic thread, and the serialized target logic frame is sent to the message queue of the main thread;

[0029] When the current running speed is N times the speed, determining a third target frame number based on the current running speed; wherein N is a positive integer greater than or equal to 2;

[0030] Serializing the third target logic frame through the battle logic thread, and sending the serialized third target logic frame to the message queue of the main thread;

[0031] The acquiring the serialized logical frame from the message queue of the main thread, and refreshing the current screen of the first target event through the main thread based on the serialized logical frame, includes:

[0032] The serialized third target logical frame is obtained from the message queue of the main thread, and based on the serialized third target logical frame, the current screen of the first target event is refreshed through the main thread.

[0033] In the disclosed embodiment, in the case of multiple speeds, the third target logical frame is determined based on the current speed. In this way, the game operation efficiency can be further improved without affecting the screen display. As a result, the game can reduce the requirements for system performance during combat or speed, and the game can run smoothly even on low-end machines with poor performance, thereby improving the applicability of the method.

[0034] In a possible implementation, before serializing the logic frame through the battle logic thread and sending the serialized logic frame to the message queue of the main thread, the method further includes:

[0035] Acquire scene initialization information of the first target event through the main thread;

[0036] Sending the scene initialization information to the battle logic thread through the main thread;

[0037] The scene initialization information is run through the battle logic thread to obtain the logic frame.

[0038] In the disclosed embodiment, before the battle starts, the scene initialization information of the first target event is obtained through the main thread, and the scene initialization information is sent to the battle logic thread through the main thread, so that the initialization of the game scene can be achieved.

[0039] In a possible implementation manner, sending the scene initialization information to the battle logic thread through the main thread includes:

[0040] The scene initialization information is sent to the battle logic thread through the main thread in the form of a smart pointer.

[0041] In the disclosed embodiment, the scene initialization information is sent to the battle logic thread by means of a smart pointer, which can improve the transmission efficiency of information.

[0042] The present disclosure provides a screen refresh device, comprising:

[0043] A thread creation module, used for creating a battle logic thread in response to the first target event being triggered, and creating a virtual machine based on the battle logic thread; wherein the virtual machine is used to run a script language file, and the battle logic thread is used to run the battle logic to obtain a logic frame;

[0044] A logic frame sending module, used for serializing the logic frame through the battle logic thread, and sending the serialized logic frame to the message queue of the main thread;

[0045] The screen refresh module is used to obtain the serialized logical frame from the message queue of the main thread, and based on the serialized logical frame, refresh the current screen of the first target event through the main thread.

[0046] In a possible implementation, the screen refresh module is specifically used to:

[0047] Based on a preset serialization access protocol, obtaining the content of the serialized logical frame;

[0048] Based on the content of the serialized logical frame, the current screen of the first target event is refreshed through the main thread.

[0049] In a possible implementation manner, the device further includes a frame number determination module, and the frame number determination module is configured to:

[0050] Based on the display frame rate of the current screen of the first target event, determining a first target frame number through the main thread, and sending the first target frame number to the battle logic thread;

[0051] The logical frame sending module is specifically used for:

[0052] Serializing the first target logic frame corresponding to the first target frame number through the battle logic thread, and sending the serialized target logic frame to the message queue of the main thread;

[0053] The screen refresh module is specifically used for:

[0054] The serialized first target logical frame is obtained from the message queue of the main thread, and based on the serialized first target logical frame, the current screen of the first target event is refreshed through the main thread.

[0055] In a possible implementation manner, the frame number determination module is further configured to:

[0056] In a case where a trigger operation for a second target event is detected, determining a second target frame number through the main thread, the second target frame number being greater than the first target frame number;

[0057] Sending the second target frame number to the battle logic thread through the main thread;

[0058] The logic frame sending module is also used for:

[0059] Serializing the second target logic frame corresponding to the second target frame number through the battle logic thread, and sending the serialized second target logic frame to the message queue of the main thread;

[0060] The screen refresh module is also used for:

[0061] The serialized second target logical frame is obtained from the message queue of the main thread, and based on the serialized second target logical frame, the current screen of the second target event is refreshed through the main thread.

[0062] In a possible implementation manner, the logical frame sending module is specifically configured to:

[0063] Determine the current running speed of the first target event through the battle logic thread;

[0064] When the current running speed is 1x, the first target logic frame corresponding to the first target frame number is serialized through the battle logic thread, and the serialized target logic frame is sent to the message queue of the main thread;

[0065] When the current running speed is N times the speed, determining a third target frame number based on the current running speed; wherein N is a positive integer greater than or equal to 2;

[0066] Serializing the third target logic frame through the battle logic thread, and sending the serialized third target logic frame to the message queue of the main thread;

[0067] The screen refresh module is specifically used for:

[0068] The serialized third target logical frame is obtained from the message queue of the main thread, and based on the serialized third target logical frame, the current screen of the first target event is refreshed through the main thread.

[0069] In a possible implementation, the device further includes:

[0070] A logic frame generation module, used for acquiring scene initialization information of the first target event through the main thread;

[0071] Sending the scene initialization information to the battle logic thread through the main thread;

[0072] The scene initialization information is run through the battle logic thread to obtain the logic frame.

[0073] In a possible implementation manner, the logical frame generation module is specifically used to:

[0074] The scene initialization information is sent to the battle logic thread through the main thread in the form of a smart pointer.

[0075] An embodiment of the present disclosure provides an electronic device, including: a processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor and the memory communicate via the bus, and when the machine-readable instructions are executed by the processor, the screen refresh method as described above is performed.

[0076] An embodiment of the present disclosure provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the screen refreshing method as described above is executed.

[0077] In order to make the above-mentioned objectives, features and advantages of the present disclosure more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0078] In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the following is a brief introduction to the drawings required for use in the embodiments. The drawings herein are incorporated into the specification and constitute a part of the specification. These drawings illustrate embodiments consistent with the present disclosure and are used together with the specification to illustrate the technical solutions of the present disclosure. It should be understood that the following drawings only illustrate certain embodiments of the present disclosure and should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can also be obtained based on these drawings without creative work.

[0079] Figure 1 A schematic diagram showing an execution subject of a screen refresh method provided by an embodiment of the present disclosure;

[0080] Figure 2 A flow chart of a screen refresh method provided by an embodiment of the present disclosure is shown;

[0081] Figure 3 A flow chart of a method for refreshing a screen based on a preset serialization protocol provided by an embodiment of the present disclosure is shown;

[0082] Figure 4 A flowchart of another screen refresh method provided by an embodiment of the present disclosure is shown;

[0083] Figure 5 A flowchart of another screen refresh method provided by an embodiment of the present disclosure is shown;

[0084] Figure 6 A flowchart of a method for refreshing a picture at multiple times the speed provided by an embodiment of the present disclosure is shown;

[0085] Figure 7 A schematic diagram showing the structure of a screen refresh device provided by an embodiment of the present disclosure is shown;

[0086] Figure 8 A schematic diagram showing the structure of another screen refreshing device provided by an embodiment of the present disclosure is shown;

[0087] Fig. 9 A schematic diagram of an electronic device provided by an embodiment of the present disclosure is shown. DETAILED DESCRIPTION

[0088] In order to make the purpose, technical scheme and advantages of the embodiments of the present disclosure clearer, the technical scheme in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only part of the embodiments of the present disclosure, rather than all of the embodiments. The components of the embodiments of the present disclosure generally described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present disclosure provided in the drawings is not intended to limit the scope of the present disclosure for protection, but merely represents the selected embodiments of the present disclosure. Based on the embodiments of the present disclosure, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present disclosure.

[0089] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.

[0090] The term "and / or" herein only describes an association relationship, indicating that three relationships may exist. For example, A and / or B may represent the following three situations: A exists alone, A and B exist at the same time, and B exists alone. In addition, the term "at least one" herein represents any combination of at least two of any one or more of a plurality of. For example, including at least one of A, B, and C may represent including any one or more elements selected from the set consisting of A, B, and C.

[0091] At present, with the widespread use of the Internet, especially mobile Internet, various social entertainment applications have emerged. Among them, the emergence of various game applications (Application, APP) has enriched people's lives. However, how to improve the running efficiency of games and facilitate users to update applications has been a goal that the industry has been pursuing.

[0092] The present disclosure provides a screen refresh method, comprising: in response to a first target event being triggered, creating a battle logic thread, and creating a virtual machine based on the battle logic thread; wherein the virtual machine is used to run a script language file, and the battle logic thread is used to run battle logic to obtain a logic frame; serializing the logic frame through the battle logic thread, and sending the serialized logic frame to a message queue of a main thread; obtaining the serialized logic frame from the message queue of the main thread, and based on the serialized logic frame, refreshing the current screen of the first target event through the main thread.

[0093] In the disclosed embodiment, in response to the first target event being triggered, a battle logic thread is created, so that the battle logic is run through the logic thread and the screen is refreshed through the main thread, that is, multiple threads are run simultaneously, thereby improving the running efficiency of the game. In addition, a virtual machine is created based on the battle logic thread, and the virtual machine is used to run the script language file, thereby supporting hot updates and improving the user experience.

[0094] See also Figure 1 , which is a schematic diagram of an execution subject of the screen refresh method provided in an embodiment of the present disclosure, wherein the execution subject of the method is an electronic device 100, wherein the electronic device 100 may include a terminal and a server. For example, the method may be applied to a terminal, and the terminal may be Figure 1 The smart phone 10, desktop computer 20, notebook computer 30, etc. shown in FIG. Figure 1 The method can also be applied to the server 40, or can be applied to the implementation environment composed of the terminal and the server 40. The server 40 can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud storage, big data and artificial intelligence platforms.

[0095] It should be noted that, in some embodiments, the server 40 can communicate with the smart phone 10, the desktop computer 20 and the laptop computer 30 respectively through the network 50. The network 50 can include various connection types, such as wired, wireless communication links or optical fiber cables, etc.

[0096] In addition, the screen refresh method may also be software running in a terminal or server, such as an application with a screen refresh function, etc. In some possible implementations, the screen refresh method may be implemented by a processor calling a computer-readable instruction stored in a memory.

[0097] See also Figure 2FIG. 1 is a flowchart of a screen refresh method provided by an embodiment of the present disclosure, and the screen refresh method includes the following S101 to S103:

[0098] S101, in response to a first target event being triggered, a battle logic thread is created, and a virtual machine is created based on the battle logic thread; wherein the virtual machine is used to run a script language file, and the battle logic thread is used to run battle logic to obtain a logic frame.

[0099] Exemplarily, the first target trigger event refers to a trigger event for a target task of a certain game application, for example, the target task may be to complete a dungeon, challenge a level, or kill a monster, etc. Specifically, the target task may vary depending on the type of game, and is not limited here. In other embodiments, the first target event may also be a game running instruction or a game start instruction, etc.

[0100] It is understandable that a game has at least one thread, which is responsible for refreshing the user interface, and is accompanied by a series of other threads as auxiliary, such as networking, computing, processing user input events, etc. The thread responsible for the user interface is called the UI (User Interface) thread, also known as the main thread.

[0101] Exemplarily, after receiving the first target trigger event, a battle logic thread can be created, and a virtual machine can be created based on the battle logic thread. In the disclosed embodiment, the battle logic thread is responsible for running the specific logic of the battle, and the virtual machine is a Lua virtual machine. The Lua virtual machine can run the fastest weakly typed scripting language and supports hot updates. Even after the application is launched, it can be continuously iterated and developed without the need for forced updates.

[0102] The scripting language may be JavaScript ("JS" for short) or Python. In addition, strongly typed languages ​​such as Java or C# can also achieve the same purpose (hot update) by accessing the corresponding virtual machine and executing in an interpreted manner.

[0103] For example, when the battle starts, the server will send the client (terminal) battlefield scene initialization information. The scene initialization information includes but is not limited to: the ID (Identity Document, identity identification), level, attributes, equipment, skin, battlefield random seed, battlefield additional accessories, etc. of the characters of the two sides. It should be noted that these scene initialization information is not deserialized and is a continuous memory segment in the memory.

[0104] That is, in some embodiments, after the battle logic thread is created, the scene initialization information of the first target event can be obtained through the main thread, and then the scene initialization information is sent to the battle logic thread through the main thread, and then the scene initialization information is run through the battle logic thread to obtain the logical frame.

[0105] Specifically, the scene initialization information can be sent to the battle logic thread through the main thread in the form of a smart pointer, so that the transmission efficiency of the scene initialization information can be improved.

[0106] Among them, a common implementation technology of smart pointers is to use reference counting. The smart pointer class associates a counter with the object pointed to by the class, and the reference count keeps track of how many objects of the class have pointers pointing to the same object.

[0107] S102, serializing the logic frame through the battle logic thread, and sending the serialized logic frame to the message queue of the main thread.

[0108] For example, after obtaining the scene initialization information, the battle logic thread can run the logic in a fixed frame manner and send the information required for display (logic frame) to the message queue of the main thread in a serialized manner.

[0109] S103, acquiring the serialized logical frame from the message queue of the main thread, and based on the serialized logical frame, refreshing the current screen of the first target event through the main thread.

[0110] Exemplarily, the main thread obtains a serialized logical frame from the message queue, and refreshes the current screen of the first target event based on the serialized logical frame.

[0111] In some embodiments, see Figure 3 As shown, when refreshing the current screen of the first target event through the main thread based on the serialized logical frame, the following S1031-1032 may be included:

[0112] S1031, based on a preset serialization access protocol, obtaining the content of the serialized logical frame.

[0113] S1032: Refresh the current screen of the first target event through the main thread based on the content of the serialized logical frame.

[0114] It is understandable that for the information exchange between the main thread and the battle logic thread, if the conventional method is used, the main thread will need to deserialize the messages synchronized by the battle logic thread, and then a large number of objects will be created, resulting in a serious time-consuming process of information exchange. In this embodiment, in order to improve the efficiency of information transmission, a special serialization and access protocol (preset serialization access protocol) is designed, which allows the main thread to directly access the message content without deserialization, thereby realizing efficient information exchange between different threads.

[0115] In the disclosed embodiment, in response to the first target event being triggered, a battle logic thread is created, so that the battle logic is run through the logic thread and the screen is refreshed through the main thread, that is, multiple threads are run simultaneously, thereby improving the running efficiency of the game. In addition, a virtual machine is created based on the battle logic thread, and the virtual machine is used to run the script language file, thereby supporting hot updates and improving the user experience.

[0116] See also Figure 4 FIG. 2 is a flowchart of another screen refresh method provided by an embodiment of the present disclosure. In this embodiment, the screen refresh method includes the following S201 to S203:

[0117] S201, in response to a first target event being triggered, creating a battle logic thread, and creating a virtual machine based on the battle logic thread; wherein the virtual machine is used to run a script language file, and the battle logic thread is used to run the battle logic to obtain a logic frame.

[0118] This step is similar to the aforementioned step S101 and will not be repeated here.

[0119] S202, based on the display frame rate of the current screen of the first target event, determine a first target frame number through the main thread, and send the first target frame number to the battle logic thread.

[0120] In the disclosed embodiment, the main thread will periodically synchronize the number of frames that can be run (the first target frame number) to the combat logic thread. The combat logic thread will run to the specified number of frames and send the result of each frame to the main thread. In this way, the information that needs to be interacted between the main thread and the combat logic thread can be reduced, further improving the game operation efficiency.

[0121] S203, serializing the first target logic frame corresponding to the first target frame number through the battle logic thread, and sending the serialized target logic frame to the message queue of the main thread.

[0122] This step is similar to the aforementioned step S102 and will not be repeated here.

[0123] S204: Acquire the serialized first target logical frame from the message queue of the main thread, and refresh the current screen of the first target event through the main thread based on the serialized first target logical frame.

[0124] This step is similar to the aforementioned step S103 and will not be repeated here.

[0125] It can be understood that during the game, in one case, the player can do nothing, and the system automatically runs the game scene and realizes the corresponding path finding; in another case, the player can perform corresponding operations on the game according to the current situation, for example, use various skills (such as using a big move), at this time, the picture will change in response to the player's operation, and the situation of the player's operation will be realized through other steps. Therefore, in some embodiments, see Figure 5 As shown, the screen refresh method further includes the following S301 to S303:

[0126] S301, when a trigger operation for a second target event is detected, determining a second target frame number through the main thread, wherein the second target frame number is greater than the first target frame number.

[0127] For example, the main thread will synchronize the second target frame rate to the battle logic thread, wherein the second target frame rate is greater than the first target frame rate, that is, the operation takes effect after a delay of a period of time.

[0128] It should be noted that in the interactive competitive game mode (PVP), if the synchronization operation takes effect in the next frame, the opponent's client will inevitably need to recalculate the logic, causing a sudden change in the screen. The more delayed frames, the higher the network delay that can be accommodated, and the worse the operation experience. Therefore, a balance needs to be struck, which is optional. It can be configured to 3 logical frames, less than 200ms.

[0129] S302: Send the second target frame number to the combat logic thread through the main thread.

[0130] S303: Serialize the second target logic frame corresponding to the second target frame number through the battle logic thread, and send the serialized second target logic frame to the message queue of the main thread.

[0131] S304: Acquire the serialized second target logical frame from the message queue of the main thread, and refresh the current screen of the second target event through the main thread based on the serialized second target logical frame.

[0132] Steps S302 to S304 are similar to steps S102 to S103 in the aforementioned method and will not be described in detail herein.

[0133] In the disclosed embodiment, when a trigger operation for a second target event is detected, the main thread sends the second target frame number to the combat logic thread, and the second target frame number is greater than the first target frame number. In this way, the game operation efficiency can be further improved in some scenarios (player operations) without affecting the screen display.

[0134] It is understandable that in order to enrich the user experience during the game, in some cases, the speed will be turned on. At different speeds, the screen refresh method will be different. Therefore, see Figure 6 As shown, the screen refresh method at different speeds may include the following S601 to S606:

[0135] S601, determine through the battle logic thread whether the current running speed of the first target event is 1x; if so, execute step S602; if not, execute step S603.

[0136] Exemplarily, in order to improve the screen refresh efficiency at different speeds, it can be determined whether the current running speed of the first target event is 1x or Nx, where N is a positive integer greater than or equal to 2, such as 2x, 4x or 8x.

[0137] Wherein, when the current running speed is 1x speed, step S602 is executed; when the current running speed is Nx speed, step S604 is executed.

[0138] S602: Serialize the first target logic frame corresponding to the first target frame number through the battle logic thread, and send the serialized target logic frame to the message queue of the main thread.

[0139] This step is similar to the aforementioned step S102 and will not be described in detail here.

[0140] S603: Serialize the first target logic frame corresponding to the first target frame number through the battle logic thread, and send the serialized target logic frame to the message queue of the main thread.

[0141] This step is similar to the aforementioned step S103 and will not be described in detail here.

[0142] S604: Determine a third target frame number based on the current running speed.

[0143] Exemplarily, in order to reduce the pressure on the battle logic thread caused by serialization, in the case of multiple speeds, the corresponding third target frame number can be determined based on the current running speed.

[0144] S605, serialize the third target logic frame through the battle logic thread, and send the serialized third target logic frame to the message queue of the main thread.

[0145] This step is similar to the aforementioned step S102 and will not be described in detail here.

[0146] S606: Acquire the serialized third target logical frame from the message queue of the main thread, and based on the serialized third target logical frame, refresh the current screen of the first target event through the main thread.

[0147] This step is similar to the aforementioned step S103 and will not be described in detail here.

[0148] The principle of dynamic frame number prediction is described below, wherein the dynamic predicted frame number may include a first target frame number, a second target frame number and a third target frame number.

[0149] Since the change of display frame rate is continuous, assuming that the current logical frame is L1, the display frame is S1, the frame rate improvement coefficient is R, and the time consumption influencing factor is C (the default value is 1), then the predicted time consumption of the next frame is R / (C*L1). When the speed is N, the next logical frame is S1+R*N / (C*L1). Therefore, the frames between [S1+1, S1+R*N / (C*L1)] do not need to synchronize display information.

[0150] Among them, R is the frame rate improvement coefficient. On a low-end machine, the frame rate is counted and the average is calculated to get a reasonable coefficient improvement value; C is the time consumption influencing factor. According to the frame rate statistics, when C≠1, the estimated time consumption and the actual time consumption are used to reversely calculate the reasonable value of C; N is the speed, which can be any value of 1, 2, 4, or 8.

[0151] It should be noted that the predicted logical frame is not equal to the actual one. For example, if a frame jumps, in actual testing, at high speed, the logical frame difference is 1 frame, and the display frame is smoothed in the main thread, so it cannot be seen. At non-high speed, the prediction will degenerate into prediction based on the frame rate limit.

[0152] In the disclosed embodiment, in the case of multiple speeds, the third target logical frame is determined based on the current speed. In this way, the game operation efficiency can be further improved without affecting the screen display. As a result, the game can reduce the requirements for system performance during combat or speed, and the game can run smoothly even on low-end machines with poor performance, thereby improving the applicability of the method.

[0153] Those skilled in the art will appreciate that, in the above method of specific implementation, the order in which the steps are written does not imply a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of the steps should be determined by their functions and possible internal logic.

[0154] Based on the same technical concept, a screen refresh method corresponding to the screen refresh method is also provided in the embodiment of the present disclosure. Since the principle of solving the problem by the device in the embodiment of the present disclosure is similar to the above-mentioned screen refresh method in the embodiment of the present disclosure, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be repeated.

[0155] Reference Figure 7 FIG. 7 is a schematic diagram of a screen refresh device 700 provided in an embodiment of the present disclosure, wherein the device includes:

[0156] The thread creation module 701 is used to create a battle logic thread in response to the first target event being triggered, and to create a virtual machine based on the battle logic thread; wherein the virtual machine is used to run a script language file, and the battle logic thread is used to run the battle logic to obtain a logic frame;

[0157] A logic frame sending module 702, used for serializing the logic frame through the battle logic thread, and sending the serialized logic frame to the message queue of the main thread;

[0158] The screen refresh module 703 is used to obtain the serialized logical frame from the message queue of the main thread, and based on the serialized logical frame, refresh the current screen of the first target event through the main thread.

[0159] In a possible implementation manner, the screen refresh module 703 is specifically configured to:

[0160] Based on a preset serialization access protocol, obtaining the content of the serialized logical frame;

[0161] Based on the content of the serialized logical frame, the current screen of the first target event is refreshed through the main thread.

[0162] See also Figure 8 As shown, in a possible implementation manner, the device further includes a frame number determination module 704, and the frame number determination module 704 is used to:

[0163] Based on the display frame rate of the current screen of the first target event, determining a first target frame number through the main thread, and sending the first target frame number to the battle logic thread;

[0164] The logic frame sending module 702 is specifically used for:

[0165] Serializing the first target logic frame corresponding to the first target frame number through the battle logic thread, and sending the serialized target logic frame to the message queue of the main thread;

[0166] The screen refresh module 703 is specifically used for:

[0167] The serialized first target logical frame is obtained from the message queue of the main thread, and based on the serialized first target logical frame, the current screen of the first target event is refreshed through the main thread.

[0168] In a possible implementation manner, the frame number determination module 704 is further configured to:

[0169] In a case where a trigger operation for a second target event is detected, determining a second target frame number through the main thread, the second target frame number being greater than the first target frame number;

[0170] Sending the second target frame number to the battle logic thread through the main thread;

[0171] The logic frame sending module 702 is also used for:

[0172] Serializing the second target logic frame corresponding to the second target frame number through the battle logic thread, and sending the serialized second target logic frame to the message queue of the main thread;

[0173] The screen refresh module 703 is also used for:

[0174] The serialized second target logical frame is obtained from the message queue of the main thread, and based on the serialized second target logical frame, the current screen of the second target event is refreshed through the main thread.

[0175] In a possible implementation manner, the logical frame sending module 702 is specifically configured to:

[0176] Determine the current running speed of the first target event through the battle logic thread;

[0177] When the current running speed is 1x, the first target logic frame corresponding to the first target frame number is serialized through the battle logic thread, and the serialized target logic frame is sent to the message queue of the main thread;

[0178] When the current running speed is N times the speed, determining a third target frame number based on the current running speed; wherein N is a positive integer greater than or equal to 2;

[0179] Serializing the third target logic frame through the battle logic thread, and sending the serialized third target logic frame to the message queue of the main thread;

[0180] The screen refresh module 703 is specifically used for:

[0181] The serialized third target logical frame is obtained from the message queue of the main thread, and based on the serialized third target logical frame, the current screen of the first target event is refreshed through the main thread.

[0182] In a possible implementation manner, the apparatus further includes a logical frame generation module 705, and the logical frame generation module 705 is configured to:

[0183] Acquire scene initialization information of the first target event through the main thread;

[0184] Sending the scene initialization information to the battle logic thread through the main thread;

[0185] The scene initialization information is run through the battle logic thread to obtain the logic frame.

[0186] In a possible implementation manner, the logical frame generation module 705 is specifically configured to:

[0187] The scene initialization information is sent to the battle logic thread through the main thread in the form of a smart pointer.

[0188] For descriptions of the processing flow of each module in the device and the interaction flow between each module, reference may be made to the relevant descriptions in the above method embodiment, which will not be described in detail here.

[0189] Based on the same technical concept, the embodiment of the present disclosure also provides an electronic device. Fig. 9 , which is a schematic diagram of the structure of an electronic device 900 provided in an embodiment of the present disclosure, including a processor 901, a memory 902, and a bus 903. The memory 902 is used to store execution instructions, including a memory 9021 and an external memory 9022; the memory 9021 is also called an internal memory, which is used to temporarily store the operation data in the processor 901 and the data exchanged with the external memory 9022 such as a hard disk. The processor 901 exchanges data with the external memory 9022 through the memory 9021.

[0190] In the embodiment of the present application, the memory 902 is specifically used to store the application code for executing the solution of the present application, and the execution is controlled by the processor 901. That is, when the electronic device 900 is running, the processor 901 communicates with the memory 902 through the bus 903, so that the processor 901 executes the application code stored in the memory 902, and then executes the method described in any of the above embodiments.

[0191] Among them, the memory 902 can be, but is not limited to, random access memory (Random Access Memory, RAM), read only memory (Read Only Memory, ROM), programmable read-only memory (Programmable Read-Only Memory, PROM), erasable programmable read-only memory (Erasable Programmable Read-Only Memory, EPROM), electrically erasable read-only memory (Electric Erasable Programmable Read-Only Memory, EEPROM), etc.

[0192] Processor 901 may be an integrated circuit chip with signal processing capabilities. The above-mentioned processor may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it may also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The disclosed methods, steps and logic block diagrams in the embodiments of the present invention may be implemented or executed. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.

[0193] It is to be understood that the structure illustrated in the embodiment of the present application does not constitute a specific limitation on the electronic device 900. In other embodiments of the present application, the electronic device 900 may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.

[0194] The present disclosure also provides a computer-readable storage medium, which stores a computer program, and when the computer program is executed by a processor, the steps of the screen refresh method in the above method embodiment are executed. The storage medium can be a volatile or non-volatile computer-readable storage medium.

[0195] The embodiment of the present disclosure further provides a computer program product, which carries a program code. The instructions included in the program code can be used to execute the steps of the screen refresh method in the above method embodiment. For details, please refer to the above method embodiment, which will not be repeated here.

[0196] The computer program product may be implemented in hardware, software or a combination thereof. In one optional embodiment, the computer program product is implemented as a computer storage medium. In another optional embodiment, the computer program product is implemented as a software product, such as a software development kit (SDK).

[0197] Those skilled in the art can clearly understand that, for the convenience and simplicity of description, the specific working process of the system and device described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here. In the several embodiments provided in the present disclosure, it should be understood that the disclosed system, device and method can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, 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 communication interfaces, and the indirect coupling or communication connection of the device or unit can be electrical, mechanical or other forms.

[0198] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0199] In addition, each functional unit in each embodiment of the present disclosure may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

[0200] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium that is executable by a processor. Based on this understanding, the technical solution of the present disclosure, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present disclosure. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0201] Finally, it should be noted that the above-described embodiments are only specific implementation methods of the present disclosure, which are used to illustrate the technical solutions of the present disclosure, rather than to limit them. The protection scope of the present disclosure is not limited thereto. Although the present disclosure is described in detail with reference to the above-described embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above-described embodiments within the technical scope disclosed in the present disclosure, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present disclosure, and should be included in the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure should be based on the protection scope of the claims.

Claims

1. A screen refresh method, characterized in that: include: In response to the first target event being triggered, a battle logic thread is created, and a virtual machine is created based on the battle logic thread; wherein the virtual machine is used to run a script language file, and the battle logic thread is used to run a battle logic to obtain a logic frame; The logic frame is serialized through the battle logic thread, and the serialized logic frame is sent to the message queue of the main thread; The serialized logical frame is obtained from the message queue of the main thread, and based on the serialized logical frame, the current screen of the first target event is refreshed through the main thread.

2. The method according to claim 1, characterized in that The refreshing of the current screen of the first target event through the main thread based on the serialized logical frame includes: Based on a preset serialization access protocol, obtaining the content of the serialized logical frame; Based on the content of the serialized logical frame, the current screen of the first target event is refreshed through the main thread.

3. The method according to claim 1, characterized in that The method further comprises: Based on the display frame rate of the current screen of the first target event, determining a first target frame number through the main thread, and sending the first target frame number to the battle logic thread; The step of serializing the logic frame through the battle logic thread and sending the serialized logic frame to the message queue of the main thread includes: Serializing the first target logic frame corresponding to the first target frame number through the battle logic thread, and sending the serialized target logic frame to the message queue of the main thread; The acquiring the serialized logical frame from the message queue of the main thread, and refreshing the current screen of the first target event through the main thread based on the serialized logical frame, includes: The serialized first target logical frame is obtained from the message queue of the main thread, and based on the serialized first target logical frame, the current screen of the first target event is refreshed through the main thread.

4. The method according to claim 3, characterized in that The method further comprises: In a case where a trigger operation for a second target event is detected, determining a second target frame number through the main thread, the second target frame number being greater than the first target frame number; Sending the second target frame number to the battle logic thread through the main thread; Serializing the second target logic frame corresponding to the second target frame number through the battle logic thread, and sending the serialized second target logic frame to the message queue of the main thread; The serialized second target logical frame is obtained from the message queue of the main thread, and based on the serialized second target logical frame, the current screen of the second target event is refreshed through the main thread.

5. The method according to claim 1 or 3, characterized in that: The step of serializing the logic frame through the battle logic thread and sending the serialized logic frame to the message queue of the main thread includes: Determine the current running speed of the first target event through the battle logic thread; When the current running speed is 1x, the first target logic frame corresponding to the first target frame number is serialized through the battle logic thread, and the serialized target logic frame is sent to the message queue of the main thread; When the current running speed is N times the speed, determining a third target frame number based on the current running speed; wherein N is a positive integer greater than or equal to 2; Serializing the third target logic frame through the battle logic thread, and sending the serialized third target logic frame to the message queue of the main thread; The acquiring the serialized logical frame from the message queue of the main thread, and refreshing the current screen of the first target event through the main thread based on the serialized logical frame, includes: The serialized third target logical frame is obtained from the message queue of the main thread, and based on the serialized third target logical frame, the current screen of the first target event is refreshed through the main thread.

6. The method according to any one of claims 1 to 5, characterized in that: Before serializing the logic frame through the battle logic thread and sending the serialized logic frame to the message queue of the main thread, the method further includes: Acquire scene initialization information of the first target event through the main thread; Sending the scene initialization information to the battle logic thread through the main thread; The scene initialization information is run through the battle logic thread to obtain the logic frame.

7. The method according to claim 6, characterized in that The sending the scene initialization information to the battle logic thread through the main thread includes: The scene initialization information is sent to the battle logic thread through the main thread in the form of a smart pointer.

8. A screen refresh device, characterized in that: include: A thread creation module, used for creating a battle logic thread in response to the first target event being triggered, and creating a virtual machine based on the battle logic thread; wherein the virtual machine is used to run a script language file, and the battle logic thread is used to run the battle logic to obtain a logic frame; A logic frame sending module, used for serializing the logic frame through the battle logic thread, and sending the serialized logic frame to the message queue of the main thread; The screen refresh module is used to obtain the serialized logical frame from the message queue of the main thread, and based on the serialized logical frame, refresh the current screen of the first target event through the main thread.

9. An electronic device, characterized in that: include: A processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor and the memory communicate via the bus, and when the machine-readable instructions are executed by the processor, the screen refresh method as described in any one of claims 1-7 is executed.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the screen refreshing method according to any one of claims 1 to 7 is executed.

Citation Information

Patent Citations

  • Method for realizing smooth loading of external picture set based on Unity 3D characteristics

    CN110941785A

  • Game data processing method and device, storage medium and electronic equipment

    CN112245905A