CocosCreator3.8 Project Practice
W rain or shine w
-
Cocos Creator3.8 Project Practice (X) Detailed Tutorial of Using protobuf Well, this concludes the tutorial on how to package proto files into typescript scripts and how to use protobuf in Cocos Creator 3.8. If you think my blog has helped you, your likes and concerns are my greatest support. If you encounter any problems, you can leave a message in the comment area. Using the protobuf.js library in Cocos Creator can easily serialize and deserialize the protocol. The protobuf environment needs to be installed using the npm command, so you need to install npm first. Once the module format and export method are determined, they can be used in script resources. File as an example for demonstration. original 2023-10-18 22:21:42 · 2617 Reading· 0 Comments -
Cocos Creator3.8 Project Practice (IX) 2D UI DrawCall Optimization Details (II) Today, we mainly introduce the DrawCall optimization cases and the experience summary of DrawCall optimization in practice. We hope to help friends in need and further deepen their understanding of DrawCall optimization. Moreover, the larger the image size is, the longer the loading time is, and it is a nonlinear growth. For example, loading one image takes longer than loading two images, which is not worth the loss. As for the selection of automatic resource mapping and manual resource mapping, you can make a reasonable choice according to the degree of optimization required by the actual Draw Call. The spacing remains the default of 2 and the widening option is checked to avoid image clipping errors and black edges. Organize UI components in the following way as far as possible. original 2023-10-09 21:34:48 · 1306 Reading· 0 Comments -
Cocos Creator3.8 Project Practice (VIII) 2D UI DrawCall Optimization Details (I) The essence of batching: In the process of rendering a frame, ensure that the rendering state of consecutive nodes is consistent, and combine as many node data as possible to submit at one time, so as to reduce the number of calls to drawing instructions, reduce the performance consumption caused by graphics API calls, and also avoid GPU frequent rendering state switching. As friends of game development know, during the development of games, DrawCall is a very important indicator for us to optimize the performance, which directly affects the overall performance of the game. The more DrawCalls are, the lower the frame rate will be, and you can clearly feel the stuttering. Each character is drawn once and added to the 2048 * 2048 character image set. When the scene is not switched, the texture will not be rebuilt, because the texture size is limited, original 2023-10-09 21:18:28 · 2281 Reading· 0 Comments -
Cocos Creator3.8 Project Practice (VII) Implementation and Use of Listview Control In cocoscreator, there is no ready-made Listview control, so we have no choice but to implement one ourselves with ScrollView. In this way, if friends with similar needs can focus on the development of business functions, they will not have to repeat the wheel building. ScrollView and item prefab are used to dynamically generate list items, adjust the spacing of item items, and support horizontal and vertical scrolling. AbsAdapter adapter is used to set data, update view page, obtain data quantity, calculate item display position, etc. The implementation of Listview in the leaderboard is taken as an example for detailed description. original 2023-10-06 23:26:27 · 2621 Reading· 10 Comments -
Cocos Creator3.8 Project Practice (VI) Implementation and Use of Combobox Control In cocoscreator, there is no Combobox control, so I have no choice but to write one myself. Background: the background image is a sprite control that responds to the click event. combobox: It is an empty node, which serves as the root node. Content Add vLayout vertical layout. Label: The selected text of the combobox is displayed. Triangle_button_flg: small triangle. DropDown: scroll control. Bg: The background is used to respond to events. Label: Display the text item. original 2023-10-06 21:59:25 · 1341 Reading· 0 Comments -
Cocos Creator3.8 Project Practice (V) How to achieve the effect of unlimited background scrolling That is, multiple background images are used. Each image and each frame are moved at the same time. When the image is moved out of the screen, its position is set to the initial position of the next image, and the position of the last image is set to the initial position of the first image. You can cycle through this process. Take the background image of 1920 * 1080 background and infinite rolling in vertical direction as an example for detailed description. In the game, we often achieve the effect of infinite scrolling of the background. How are these effects achieved? The third figure is 0, - 1080 * 2. The fourth figure 0, - 1080 * 3. The fifth figure is 0, - 1080 * 4. The first figure 0, - 1080. The first picture is 0, 0. The sixth picture, and so on original 2023-10-06 20:58:31 · 1318 Reading· 1 Comments -
Cocos Creator3.8 Project Practice (IV) Skillfully Stretching with Nine grid Images Usually, the UI resources are pictures, which are also the resource type that accounts for the most resources. The UI resources in the game are the most important part of human-computer interaction, so the quality requirements are very high. Usually, rgb32 bit true color is used, which leads to a large amount of resources. Usually, when the UI resources are packaged, they are displayed in the form of atlas. When they are loaded into memory, they are loaded in whole blocks. If the UI is not optimized well, the memory overhead will increase. Move the mouse to the split line, and you can see that the cursor shape has changed. At this time, you can press and drag the mouse to change the position of the split line. We can see that there is a circle of green lines around the image, indicating the current position of the division line of the Jiugongs. You can use the mouse wheel to zoom in on the image preview, which is convenient for precise adjustment of the border position. original 2023-10-04 10:19:43 · 1873 Reading· 0 Comments -
Cocos Creator3.8 Project Practice (III) Removing Scrollview Background Color and Invalid Label Alignment Settings The reason is that the overflow parameter is none by default. You need to set the overflow parameter to the clamp mode to solve the problem perfectly. Set the color of scrollview as transparent? No, this will cause the view node to be completely transparent. original 2023-09-27 10:56:47 · 640 Reading· 0 Comments -
Cocos Creator3.8 Project Practice (II) Bugs Caused by Binding Events in the Cocos Creator Editor Multiple buttons in the editor are bound to the same script. Each time a button event is bound, the script will be loaded once. As for events bound to multiple buttons, the script will be loaded multiple times, causing the initialization interface, such as onload, to be executed multiple times. At this time, there are other messages listening in onload, which are also executed many times, leading to logic confusion. Multiple buttons in the editor are bound to the same script, and events are configured. Other messages in the script are monitored, causing logic confusion. Delete the button event in the editor, adjust it to add the button attribute in the script code, and bind the event manually. original 2023-09-26 09:54:59 · 724 Reading· 0 Comments -
Cocos Creator3.8 Project Practice (I) Cocos creator prefab cannot display content The cocos creator prefab cannot display the content, or only part of the content is displayed. Change the layer where the prefab node is located to the UI_2D layer to display it. The layer where the prefab node is located is default by default. original 2023-09-25 14:02:13 · 745 Reading· 0 Comments