A high-efficiency export method, system and medium for Cocos prefabs
By configuring the method package and processing the program package to generate a layer information array, the problem of low efficiency in building prefabricated objects in Cocos Creator in the existing technology is solved, and fast export and high-fidelity interface construction are achieved, which improves the efficiency and quality of game development.
Patent Information
- Application Number
- CN202111593132.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-24
- Publication Date
- 2025-09-19
- Estimated Expiration
- 2041-12-24
AI Technical Summary
The existing Cocos Creator prefab construction method consumes a lot of time and labor costs, and affects the efficiency of game development, especially due to the high mechanical repetition and low interface construction restoration.
This paper provides an efficient method for Cocos prefabs, including a layer generation module, a program file generation module, and a prefab construction module. By configuring method packages and processing program packages, a layer information array is generated and the interface is built in the Cocos engine. Layer clipping, recognition, and serialization procedures are used to improve layer processing efficiency.
It enables the rapid export of Cocos prefabs from PS files, reduces the workload of image cutting and interface construction, improves the restoration of interface element layout and game development quality, and improves development efficiency.
Smart Images

Figure CN114259730B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of game development technology, and in particular to a high-efficiency export method, system and medium for Cocos prefabricated objects. Background Art
[0002] In the prior art, when using Cocos Creator for game development, building Cocos Creator prefabs based on the interface designed by the artist is an extremely critical development step. However, during this development step, the following problems exist that reduce the quality of game development:
[0003] First, the image-cutting process by artists and the process by client developers to build the game interface based on the image-cutting process are highly repetitive and time-consuming, which reduces game development efficiency.
[0004] Secondly, the client-side interface construction process can only be based on the design drawings. Without accurate coordinate information or position information of the elements on the design drawings to accurately locate the elements, in order to avoid wasting a lot of time again, without the use of auxiliary annotation tools, the interface construction will be less accurate, affecting the quality of game development;
[0005] In summary, the existing Cocos Creator prefab construction method consumes a lot of time and labor costs, and it will affect the development quality of the game to a certain extent. Summary of the Invention
[0006] The present invention mainly solves the problem that the existing Cocos Creator prefab construction method consumes a lot of time and labor costs, and affects the quality of game development to a certain extent.
[0007] To solve the above technical problems, the present invention adopts a technical solution: providing a high-efficiency export method for Cocos prefabs, comprising the following steps:
[0008] Steps to generate the first layer:
[0009] Configure a method package, obtain a PS file, and generate a plurality of first layers to be processed based on the method package and the PS file;
[0010] Steps to generate program files:
[0011] Configuring a processing package, creating a root node, and performing a loop traversal processing operation based on the processing package, the root node, and the first layers to be processed to obtain a first program file;
[0012] Procedure for calling program files:
[0013] The Cocos engine is configured to perform an interface building operation based on the processing program package, the first program file, and the Cocos engine.
[0014] As an improved solution, the method package is configured with a first method;
[0015] The processing program package is configured with a layer clipping program, a layer identification program, a serialization program and a deserialization program;
[0016] The root node is configured with a plurality of child node arrays, and the child node arrays are provided with a position information storage character bit and a size information storage character bit.
[0017] The Cocos engine is configured with a prefab creation interface and a prefab filling interface.
[0018] As an improved solution, the step of generating a plurality of first layers to be processed based on the method package and the PS file further includes:
[0019] Export the first image file and the first layer layout file of the PS file; call the first method to generate a first copy file of the first image file; identify several sublayers of the first copy file based on the first layer layout file; set several of the sublayers as several of the first layers to be processed respectively.
[0020] As an improved solution, the loop traversal processing operation includes:
[0021] Setting a transparency threshold; counting a first number of the first layers to be processed; performing hiding processing on the first layers to be processed respectively to obtain a number of hidden sub-layers; and selecting a number of first sub-node arrays from the sub-node arrays according to the first number;
[0022] Based on the layer clipping procedure, the layer identification procedure, the transparency threshold, and the plurality of first sub-node arrays, a layer processing step is performed on each of the plurality of hidden sub-layers to obtain a plurality of layer information arrays;
[0023] An empty node object is created, and a plurality of layer information arrays are placed into the empty node object to obtain a hierarchical structure object to be serialized; and the serialization program is called to serialize the hierarchical structure object to be serialized to obtain the first program file.
[0024] As an improved solution, the layer processing step includes:
[0025] Display the hidden sublayer to obtain a displayed sublayer;
[0026] Setting a layer division unit, dividing the display sub-layer into a plurality of sub-layer areas according to the layer division unit; calling the layer identification program to identify a plurality of first transparencies corresponding to the plurality of sub-layer areas;
[0027] comparing the transparency threshold with a plurality of the first transparencies, and setting the sub-layer area corresponding to the first transparencies reaching the transparency threshold as the area to be cropped;
[0028] Calling the layer clipping program to remove the layer corresponding to the to-be-clipped area on the display sublayer; setting the display sublayer after removing the to-be-clipped area as the first to-be-identified layer;
[0029] An information identification step is performed based on the layer identification program, the first sub-node array, and the first layer to be identified to obtain the layer information array.
[0030] As an improved solution, the information identification step includes:
[0031] Calling the layer recognition program to identify first layer size information of the first layer to be recognized; establishing a first coordinate system in the first copy file; calling the layer recognition program to identify first layer coordinate information of the first layer to be recognized located in the first copy file based on the first coordinate system; after obtaining the first layer size information and the first layer coordinate information, performing the hiding process on the first layer to be recognized;
[0032] The first layer coordinate information is set as the first layer position information; the first position information storage character bit and the first size information storage character bit in the first child node array are identified; the first layer position information is first placed in the first position information storage character bit, and then the first layer size information is placed in the first size information storage character bit to obtain the layer information array.
[0033] As an improved solution, the interface building operation includes:
[0034] Accessing the development editor of the Cocos engine; calling the prefab creation interface to create an initial prefab in the development editor; reading the first program file, and calling the deserialization program to deserialize the first program file to obtain a hierarchical structure object to be identified;
[0035] The prefab filling interface is called to fill a plurality of hierarchical nodes in the initial prefab according to the plurality of first layer position information and the plurality of first layer size information in the hierarchical structure object to be identified; and a plurality of interface elements are constructed in the initial prefab based on the plurality of hierarchical nodes.
[0036] As an improved solution, the first method is a duplicate method;
[0037] The image format of the first image file is PNG format;
[0038] The first program file is a Json file.
[0039] The present invention also provides a high-efficiency export system for Cocos prefabs, comprising:
[0040] Layer generation module, program file generation module and prefab construction module;
[0041] The layer generation module is used to configure a method package and obtain a PS file, and the layer generation module generates a plurality of first layers to be processed based on the method package and the PS file;
[0042] The program file generation module is used to configure a processing program package and create a root node. The program file generation module performs a loop traversal processing operation based on the processing program package, the root node and the first layers to be processed to obtain a first program file;
[0043] The prefab construction module is used to configure the Cocos engine. The prefab construction module performs an interface construction operation based on the processing program package, the first program file and the Cocos engine to obtain a first prefab.
[0044] The present invention also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the high-efficiency export method of the Cocos prefab are implemented.
[0045] The beneficial effects of the present invention are:
[0046] 1. The high-efficiency export method of Cocos prefabs described in the present invention can quickly export Cocos prefabs directly from PS files, reducing the workload of cutting pictures and interface construction. At the same time, interface element layout can be constructed based on accurate position information and size information, further improving the restoration degree of prefab export, improving game development quality and development efficiency, making up for the shortcomings of existing technologies, and having certain application value.
[0047] 2. The high-efficiency export system of Cocos prefabricated bodies described in the present invention can realize the rapid export of Cocos prefabricated bodies directly from PS files through the mutual cooperation of the layer generation module, the program file generation module and the prefabricated body construction module, thereby reducing the workload of cutting pictures and building interfaces. At the same time, the layout of interface elements can be built according to accurate position information and size information, further improving the restoration degree of prefabricated body export, improving the quality and efficiency of game development, making up for the shortcomings of the existing technology, and having certain application value.
[0048] 3. The computer-readable storage medium described in the present invention can realize the coordination of the guiding layer generation module, the program file generation module and the prefabricated body construction module, thereby realizing the rapid export of Cocos prefabricated bodies directly from PS files, reducing the workload of cutting pictures and building interfaces, and at the same time, can lay out and build interface elements according to accurate position information and size information, further improving the restoration degree of prefabricated body export, improving the quality and efficiency of game development, making up for the shortcomings of the existing technology, having certain application value, and effectively improving the operability of the high-efficiency export method of Cocos prefabricated bodies. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] In order to more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the specific embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0050] Figure 1 This is a flow chart of the high-efficiency export method of Cocos prefabs described in Example 1 of the present invention;
[0051] Figure 2 This is a schematic diagram of a specific process of the high-efficiency export method of Cocos preforms described in Example 1 of the present invention;
[0052] Figure 3 This is an architectural diagram of the efficient export system for Cocos prefabs described in Example 2 of the present invention. DETAILED DESCRIPTION
[0053] The preferred embodiments of the present invention are described in detail below with reference to the accompanying drawings so that the advantages and features of the present invention can be more easily understood by those skilled in the art, thereby making a clearer and more precise definition of the protection scope of the present invention.
[0054] In the description of the present invention, it should be noted that the embodiments described in the present invention are only part of the embodiments of the present invention, rather than all of the embodiments; based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making any creative work are within the scope of protection of the present invention.
[0055] In the description of the present invention, it should be noted that the term “first” is only used for descriptive purposes and should not be understood as indicating or implying relative importance.
[0056] In the description of the present invention, it should be noted that the high-efficiency export method of a Cocos prefab provided in this embodiment 1 is applied to the relevant steps of the design process, the cutting process, and the interface building process in the Cocos prefab export process;
[0057] In the description of the present invention, it should be noted that: Cocos Creator is a game development engine; PS (Photoshop) is an image processing program; PNG is a bitmap format that uses a lossless compression algorithm.
[0058] Example 1
[0059] This embodiment provides a high-efficiency export method for Cocos prefabs, such as Figure 1 and Figure 2 As shown, the following steps are included:
[0060] S100, first layer generation step, specifically including:
[0061] S110, configuring a method package, obtaining a PS file, and generating a plurality of first layers to be processed based on the method package and the PS file;
[0062] Specifically, the method package is configured with a first method; in this embodiment, the method package is configured according to programming language adaptability. In this embodiment, the first method is a duplicate method, which is used to generate a copy of a document;
[0063] Specifically, the first image file and the first layer layout file of the PS file are exported; the first image file is an image file with a specific layout design that is integrated from the image resources corresponding to each element in the design interface of the PS according to the layout method of each element in the interface; the first layer layout file corresponds to the position information, size information, corresponding image information and element structure information between the layers of the images corresponding to each element in the first image file; the first method is called to generate a first copy file of the first image file, and all operations are subsequently performed on the first copy file to prevent contamination of the original file; based on the first layer layout file, several sub-layers of the first copy file are identified, and the several sub-layers are several layers corresponding to the images of the above-mentioned elements in the first copy file; several of the sub-layers are set as several of the first to-be-processed layers; several of the first to-be-processed layers are layers that need to be subsequently identified and traversed; in this embodiment, the image format of the exported first image file is PNG format, thereby improving the scope of application and export efficiency of this method.
[0064] Correspondingly, part of the core JSX code in step S100 is as follows:
[0065] / ** Export specific layers * /
[0066] function doExportArtLayer(artLayer) {
[0067] if (artLayer.kind == LayerKind.SMARTOBJECT &&artLayer.name.indexOf('_content') == 0) {
[0068] return doExportSmartObject(artLayer);
[0069] }
[0070] var node = new Node(artLayer);
[0071] artLayer.visible = true;
[0072] node.onExportPNG(duppedPsd.duplicate());
[0073] artLayer.visible = false;
[0074] return node;
[0075] }
[0076] S200, program file generation step, specifically including:
[0077] S210: Configure a processing package, create a root node, and perform a loop traversal processing operation based on the processing package, the root node, and the first layers to be processed to obtain a first program file. In this embodiment, the processing package is adaptively configured based on different programming languages and development environments. In this embodiment, the root node is a Node object, which is a custom class and includes, but is not limited to, position information, size information, and child node attribute information.
[0078] Specifically, the processing program package is configured with a layer clipping program, a layer identification program, a serialization program, and a deserialization program; the layer clipping program is used to trim and clip the layers in the copy file; the layer identification program is used to confirm the relevant position information and size information of the layers in the copy file; the serialization program is used to convert the Node object processed in this step into an executable Json file; and the deserialization program is used to restore the Json file to an executable object.
[0079] Specifically, the root node is configured with a plurality of child node arrays, each of which is provided with a position information storage character position and a size information storage character position; the child node array is provided with the relevant information identified in the layer;
[0080] Specifically, the loop traversal processing operation includes:
[0081] Setting a transparency threshold; in this embodiment, the transparency threshold is a transparency value corresponding to a layer area displayed as transparent in the layer; counting a first number of the first layers to be processed; performing hiding processing on the first layers to be processed to obtain a number of hidden sub-layers, wherein the hiding processing is to first hide the first layers to be processed; selecting a number of first sub-node arrays from the number of sub-node arrays according to the first number, i.e., the number of the first sub-node arrays is the first number, and corresponds to the number of sub-node arrays respectively;
[0082] Based on the layer clipping program, the layer identification program, the transparency threshold and the plurality of first sub-node arrays, the layer processing step is respectively performed on the plurality of the hidden sub-layers to obtain a plurality of layer information arrays; in this step, the layer processing step is performed on each hidden sub-layer simultaneously to further improve the processing efficiency; an empty node object is created, and the empty node object has the same properties as the Node object, and is used to store the layer information array obtained after processing; correspondingly, the plurality of the layer information arrays are placed into the empty node object to obtain a hierarchical structure object to be serialized, and the hierarchical structure object to be serialized is a hierarchical structure layout standard information system that can be used as a basis for prefabricated body construction in subsequent steps; the serialization program is called to serialize the hierarchical structure object to be serialized to obtain the first program file; serialization is a serialization operation commonly used in programming languages, which converts the execution object into a byte sequence. In this embodiment, the first program file is a Json file;
[0083] Specifically, the layer processing step performed on each hidden sub-layer includes:
[0084] Displaying the hidden sublayer to obtain a display sublayer;
[0085] A layer division unit is set. In this embodiment, in order to improve accuracy, the layer division unit is a pixel unit; a number of sub-layer areas are divided on the display sub-layer according to the layer division unit; the layer recognition program is called to identify a number of first transparencies corresponding to the sub-layer areas; the transparency threshold and the first transparencies are compared, and the sub-layer area corresponding to the first transparencies that reach the transparency threshold is set as the area to be cropped; that is, the sub-layer area that reaches the transparency threshold is the transparent part on the display sub-layer and needs to be cropped; therefore, the layer cropping program is called to remove the layer on the display sub-layer corresponding to the area to be cropped; the display sub-layer after removing the area to be cropped is set as the first layer to be identified; based on the layer recognition program, the first sub-node array and the first layer to be identified, an information identification step is performed to obtain the layer information array.
[0086] Specifically, the information identification step includes:
[0087] The layer recognition program is called to identify first layer size information of the first layer to be recognized. The first layer size information confirms the layer size of the first layer to be recognized. A first coordinate system is established in the first copy file. In this embodiment, the first coordinate system is a 2D coordinate system having an x-axis and a y-axis. Accordingly, the first coordinate system is adaptively set according to the image resource type corresponding to the first copy file. The layer recognition program is called to identify first layer coordinate information of the first layer to be recognized in the first copy file based on the first coordinate system. After obtaining the first layer size information and the first layer coordinate information, the first layer to be recognized is hidden, that is, the first layer to be recognized is further hidden. Therefore, the first layer coordinate information is set as the first layer position information of the first layer to be recognized. The character bit for storing the first position information and the character bit for storing the first size information in the first child node array are identified. The first layer position information is first placed in the character bit for storing the first position information, and then the first layer size information is placed in the character bit for storing the first size information to obtain the layer information array. Therefore, in this embodiment, the layer processing step is performed on each hidden sublayer, thereby recursively traversing each hidden sublayer to achieve complete information recognition and integration.
[0088] Specifically, part of the core JSX code of step S200 is as follows:
[0089] / ** Set whether the layer and its sublayers are visible* /
[0090] function setCascadeVisible(obj, visible) {
[0091] obj.visible = visible;
[0092] if (obj.layers) {
[0093] for (var i = 0; i < obj.layers.length; i++) {
[0094] setCascadeVisible(obj.layers[i], visible);
[0095] }
[0096] }
[0097] }
[0098] S300, program file calling step, specifically including:
[0099] S310: Configuring the Cocos engine to perform interface building operations based on the processing package, the first program file, and the Cocos engine. In this embodiment, step S300 completes the final prefab export step. The main principle is to import the first program file obtained in the above step into the Cocos engine, thereby achieving a high-fidelity game interface construction based on the first program file.
[0100] Specifically, the Cocos engine is configured with a prefab creation interface and a prefab filling interface; the prefab creation interface and the prefab filling interface are respectively related functional interfaces in the Cocos engine. In this embodiment, the definition of the name is only for description purposes;
[0101] Specifically, the interface building operation includes:
[0102] Access the development editor of the Cocos engine; call the prefab creation interface to create an initial prefab in the development editor; first read the first program file obtained in the above step (i.e., based on the PS file), call the deserialization program to deserialize the first program file, and obtain the hierarchical structure object to be identified;
[0103] The prefab filling interface is called to fill a number of hierarchical nodes in the initial prefab according to the first layer position information and the first layer size information in the hierarchical structure object to be identified, that is, new nodes at all levels are recreated in the initial prefab, and corresponding coordinate information and size information are assigned to the new nodes at all levels based on the first layer position information and the first layer size information, and corresponding image resources are assigned based on the first copy file; finally, a number of interface elements are constructed in the initial prefab based on the hierarchical nodes to complete high-precision interface construction.
[0104] Correspondingly, part of the core JavaScript code of step S300 is as follows:
[0105] / / Read layout information and deserialize
[0106] let json = fs.readFileSync(assetInfo.path, {
[0107] encoding: 'utf8'
[0108] });
[0109] let obj = JSON.parse(json);
[0110] / / Create a new node
[0111] Editor.Ipc.sendToPanel(
[0112] "scene",
[0113] "scene:create-node-by-classid",
[0114] `${gFileName}`,
[0115] "",
[0116] "" );
[0118] setTimeout(() => {
[0119] / / Select the new node and save it as a prefab
[0120] let newNode = Editor.Selection.curSelection("node")[0];
[0121] Editor.Ipc.sendToPanel(
[0122] "scene",
[0123] "scene:create-prefab",
[0124] `${newNode}`,
[0125] gTargetUrl );
[0127] setTimeout(() => {
[0128] Correspondingly, through the high-efficiency export method of Cocos prefabs described in this embodiment, the relevant image files and layout files in Photoshop can be directly exported and converted into Json files. Subsequently, the Json files obtained based on the relevant image files and layout files of Photoshop are directly imported into CocosCreator, and through deserialization processing and parsing and reading operations, the corresponding prefabs can be quickly built in Cocos Creator, saving the time of artists in cutting pictures. At the same time, based on the obtained layout information, the construction restoration degree of the prefab is improved, which makes up for the shortcomings of the existing technology.
[0129] Example 2
[0130] This embodiment is based on the same inventive concept as the high-efficiency export method for Cocos preforms described in Example 1, and further provides a high-efficiency export system for Cocos preforms, such as Figure 3 As shown, it includes: a layer generation module, a program file generation module and a prefab construction module;
[0131] In the high-efficiency export system of the Cocos prefab, the layer generation module is used to configure a method package and obtain a PS file, and the layer generation module generates a plurality of first layers to be processed based on the method package and the PS file;
[0132] Specifically, the method package is configured with a first method; the first method is a duplicate method;
[0133] Specifically, the layer generation module exports the first image file and the first layer layout file of the PS file; the layer generation module calls the first method to generate a first copy file of the first image file; the layer generation module identifies several sub-layers of the first copy file based on the first layer layout file; the layer generation module sets several of the sub-layers as several of the first layers to be processed.
[0134] In the high-efficiency export system of the Cocos prefab, the program file generation module is used to configure a processing package and create a root node, and the program file generation module performs a loop traversal processing operation based on the processing package, the root node and the first layers to be processed to obtain a first program file;
[0135] Specifically, the processing program package is configured with a layer clipping program, a layer identification program, a serialization program, and a deserialization program; the root node is configured with a plurality of child node arrays, and the child node arrays are provided with a character bit for storing position information and a character bit for storing size information;
[0136] Specifically, the loop traversal processing operation includes: the program file generation module sets a transparency threshold; the program file generation module counts a first number of the first layers to be processed; the program file generation module performs hiding processing on the first layers to be processed respectively to obtain a number of hidden sub-layers; the program file generation module selects a number of first sub-node arrays from the sub-node arrays according to the first number; the program file generation module performs layer processing steps on the hidden sub-layers based on the layer clipping program, the layer recognition program, the transparency threshold and the first sub-node arrays to obtain a number of layer information arrays; the program file generation module creates an empty node object, and the program file generation module places the layer information arrays into the empty node object to obtain a hierarchical structure object to be serialized; the program file generation module calls the serialization program to perform serialization processing on the hierarchical structure object to be serialized to obtain the first program file;
[0137] Specifically, the layer processing steps include:
[0138] The program file generation module displays the hidden sublayer to obtain a displayed sublayer; the program file generation module sets a layer division unit and divides a plurality of sublayer areas on the displayed sublayer according to the layer division unit; the program file generation module calls the layer recognition program to identify a plurality of first transparencies corresponding to the plurality of sublayer areas; the program file generation module compares the transparency threshold with the plurality of first transparencies, and the program file generation module sets the sublayer area corresponding to the first transparencies that reach the transparency threshold as an area to be cropped; the program file generation module calls the layer cropping program to remove the layer on the displayed sublayer corresponding to the area to be cropped; the program file generation module sets the displayed sublayer after the area to be cropped is removed as a first layer to be identified; the program file generation module performs an information identification step based on the layer recognition program, the first subnode array, and the first layer to be identified to obtain the layer information array.
[0139] Specifically, the information identification step includes:
[0140] The program file generation module calls the layer recognition program to identify the first layer size information of the first layer to be recognized; the program file generation module establishes a first coordinate system in the first copy file; the program file generation module calls the layer recognition program to identify the first layer coordinate information of the first layer to be recognized located in the first copy file based on the first coordinate system; after the program file generation module obtains the first layer size information and the first layer coordinate information, the program file generation module performs the hiding processing on the first layer to be recognized; the program file generation module sets the first layer coordinate information as the first layer position information; the program file generation module identifies the first position information storage character bit and the first size information storage character bit in the first child node array; the program file generation module first places the first layer position information into the first position information storage character bit, and then the program file generation module places the first layer size information into the first size information storage character bit to obtain the layer information array.
[0141] In the high-efficiency export system of the Cocos prefab, the prefab construction module is used to configure the Cocos engine, and the prefab construction module performs an interface construction operation based on the processing program package, the first program file and the Cocos engine to obtain a first prefab;
[0142] Specifically, the Cocos engine is configured with a prefab creation interface and a prefab filling interface;
[0143] Specifically, the interface building operation includes: the prefab construction module accesses the development editor of the Cocos engine; the prefab construction module calls the prefab creation interface to create an initial prefab in the development editor; reads the first program file, and calls the deserialization program to deserialize the first program file to obtain the hierarchical structure object to be identified; the prefab construction module calls the prefab filling interface to fill several hierarchical nodes in the initial prefab according to several first layer position information and several first layer size information in the hierarchical structure object to be identified; the prefab construction module constructs several interface elements in the initial prefab based on several hierarchical nodes.
[0144] Example 3
[0145] This embodiment provides a computer-readable storage medium, including:
[0146] The storage medium is used to store computer software instructions used to implement the high-efficiency export method for Cocos preforms described in the above-mentioned embodiment 1, which includes a program for executing the above-mentioned high-efficiency export method for Cocos preforms; specifically, the executable program can be built into the high-efficiency export system for Cocos preforms described in embodiment 2, so that the high-efficiency export system for Cocos preforms can implement the high-efficiency export method for Cocos preforms described in embodiment 1 by executing the built-in executable program.
[0147] In addition, the computer-readable storage medium of this embodiment may adopt any combination of one or more computer-readable storage media, wherein the computer-readable storage medium includes electrical, optical, electromagnetic, infrared or semiconductor systems, devices or components, or any combination thereof.
[0148] Different from the existing technology, the high-efficiency export method, system and medium of Cocos prefabs in this application can quickly export Cocos prefabs directly from PS files through this method, reducing the workload of cutting pictures and interface construction. At the same time, the interface element layout can be constructed according to accurate position information and size information, further improving the restoration degree of prefab export. This system provides effective technical support for this method, ultimately improving the quality and efficiency of game development, making up for the shortcomings of the existing technology, and having certain application value.
[0149] The serial numbers of the embodiments disclosed in the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.
[0150] Those skilled in the art will appreciate that all or part of the steps for implementing the above embodiments may be accomplished by hardware, or by programs instructing the relevant hardware to complete the program, which may be stored in a computer-readable storage medium. The above-mentioned storage medium may be a read-only memory, a disk, or an optical disk, etc.
[0151] The above descriptions are merely embodiments of the present invention and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention's description and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.
Claims
1. A high-efficiency export method for Cocos prefabs, characterized in that: The following steps are involved: Steps to generate the first layer: Configure a method package, obtain a PS file, and generate a plurality of first layers to be processed based on the method package and the PS file; Steps to generate program files: Configuring a processing package, creating a root node, and performing a loop traversal processing operation based on the processing package, the root node, and the first layers to be processed to obtain a first program file; Procedure for calling program files: Configuring the Cocos engine to perform an interface building operation based on the processing program package, the first program file, and the Cocos engine; The method package is configured with a first method; the processing program package is configured with a layer clipping program, a layer identification program, a serialization program, and a deserialization program; the root node is configured with a plurality of child node arrays, and the child node arrays are provided with a position information storage character bit and a size information storage character bit; the Cocos engine is configured with a prefabricated body creation interface and a prefabricated body filling interface; The step of generating a plurality of first layers to be processed based on the method package and the PS file further includes: exporting a first image file and a first layer layout file of the PS file; calling the first method to generate a first copy file of the first image file; identifying a plurality of sublayers of the first copy file based on the first layer layout file; and setting the plurality of sublayers to be the plurality of first layers to be processed; The loop traversal processing operation includes: setting a transparency threshold; counting a first number of the first layers to be processed; hiding the first layers to be processed respectively to obtain a number of hidden sub-layers; selecting a number of first sub-node arrays from the sub-node arrays according to the first number; performing layer processing steps on the hidden sub-layers based on the layer clipping program, the layer recognition program, the transparency threshold and the first sub-node arrays to obtain a number of layer information arrays; creating an empty node object, placing the layer information arrays into the empty node object to obtain a hierarchical structure object to be serialized; calling the serialization program to serialize the hierarchical structure object to be serialized to obtain the first program file.
2. The high-efficiency export method for Cocos preforms according to claim 1, characterized in that: The layer processing steps include: Display the hidden sublayer to obtain a displayed sublayer; Setting a layer division unit, dividing the display sub-layer into a plurality of sub-layer areas according to the layer division unit; calling the layer identification program to identify a plurality of first transparencies corresponding to the plurality of sub-layer areas; comparing the transparency threshold with a plurality of the first transparencies, and setting the sub-layer area corresponding to the first transparencies reaching the transparency threshold as the area to be cropped; Calling the layer clipping program to remove the layer corresponding to the to-be-clipped area on the display sublayer; setting the display sublayer after removing the to-be-clipped area as the first to-be-identified layer; An information identification step is performed based on the layer identification program, the first sub-node array, and the first layer to be identified to obtain the layer information array.
3. The high-efficiency export method for Cocos preforms according to claim 2, characterized in that: The information identification step includes: Calling the layer recognition program to identify first layer size information of the first layer to be recognized; establishing a first coordinate system in the first copy file; calling the layer recognition program to identify first layer coordinate information of the first layer to be recognized located in the first copy file based on the first coordinate system; after obtaining the first layer size information and the first layer coordinate information, performing the hiding process on the first layer to be recognized; The first layer coordinate information is set as the first layer position information; the first position information storage character bit and the first size information storage character bit in the first child node array are identified; the first layer position information is first placed in the first position information storage character bit, and then the first layer size information is placed in the first size information storage character bit to obtain the layer information array.
4. The high-efficiency export method for Cocos preforms according to claim 3, characterized in that: The interface building operation includes: Accessing the development editor of the Cocos engine; calling the prefab creation interface to create an initial prefab in the development editor; reading the first program file, and calling the deserialization program to deserialize the first program file to obtain a hierarchical structure object to be identified; The prefab filling interface is called to fill a plurality of hierarchical nodes in the initial prefab according to the plurality of first layer position information and the plurality of first layer size information in the hierarchical structure object to be identified; and a plurality of interface elements are constructed in the initial prefab based on the plurality of hierarchical nodes.
5. The high-efficiency export method for Cocos preforms according to claim 4, characterized in that: The first method is the duplicate method; The image format of the first image file is PNG format; The first program file is a Json file.
6. A high-efficiency export system for Cocos preforms based on a high-efficiency export method for Cocos preforms according to any one of claims 1 to 5, characterized in that: include: Layer generation module, program file generation module and prefab construction module; The layer generation module is used to configure a method package and obtain a PS file, and the layer generation module generates a plurality of first layers to be processed based on the method package and the PS file; The program file generation module is used to configure a processing program package and create a root node. The program file generation module performs a loop traversal processing operation based on the processing program package, the root node and the first layers to be processed to obtain a first program file; The prefab construction module is used to configure the Cocos engine. The prefab construction module performs an interface construction operation based on the processing program package, the first program file and the Cocos engine to obtain a first prefab.
7. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the high-efficiency export method for Cocos preforms according to any one of claims 1 to 5.