网游中一个技巧
当我们在开发网络游戏客户端时经常会(肯定会)开一个线程负责接收,发送网络消息,这时我们必然会碰到一些问题如: 在一些对战列表中随时有玩家上下线,这时我们应该会涉及UI线程(主线程)和 网络线程的同步问题: 如果直接在网络线程中获得数据后直接使用
当我们在开发网络游戏客户端时经常会(肯定会)开一个线程负责接收,发送网络消息,这时我们必然会碰到一些问题如:
在一些对战列表中随时有玩家上下线,这时我们应该会涉及UI线程(主线程)和 网络线程的同步问题:
如果直接在网络线程中获得数据后直接使用的话,肯定会出现各种奇怪的问题。所以一个通用的做法是:
用一个变量来判断:m_bFresh
void UserList::visit(void)
{
CCLayer::visit();
if ( m_bFresh ) {
upDataUserList();
}
m_bInGame = true;
}
因为visit 会一直调用所以当判断可以刷新时直接刷就行了。
void UserList::upDataUserList()
{
m_pUserList = NET_MANAGER->getUserList(); 这个是最新的数据
m_pTableView->reloadData();
m_bFresh = !m_bFresh;
}

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

On April 24, the two-dimensional anime fighting online game "Elsword" will open a new career for Lydia. The crazy researcher who is obsessed with rifts and attracted by taboos will bring players a new experience! "Elsword"'s latest character "Lydia" has attracted the love and pursuit of the majority of players with its unique independent plot, village and dungeon. She is a highly mobile character with a unique ice ax weapon and exclusive hook rope. The character uses the magic of the ore to launch exciting attacks, bringing players a very refreshing passion for adventure! This time, Lidya’s third branch of career—crazy researcher—is open. Let’s find out about it together! The "Elsword" game has four branches of growth routes for each character. Each branch has a different plot direction and characteristics. Players can choose

This AI-assisted programming tool has unearthed a large number of useful AI-assisted programming tools in this stage of rapid AI development. AI-assisted programming tools can improve development efficiency, improve code quality, and reduce bug rates. They are important assistants in the modern software development process. Today Dayao will share with you 4 AI-assisted programming tools (and all support C# language). I hope it will be helpful to everyone. https://github.com/YSGStudyHards/DotNetGuide1.GitHubCopilotGitHubCopilot is an AI coding assistant that helps you write code faster and with less effort, so you can focus more on problem solving and collaboration. Git

Journey through the vastness and set foot on the journey to the west! Today, Zhengtu IP officially announced that it will launch a cross-border cooperation with CCTV animation "Journey to the West" to jointly create a cultural feast that combines tradition and innovation! This cooperation not only marks the in-depth cooperation between the two major domestic classic brands, but also demonstrates the unremitting efforts and persistence of the Zhengtu series on the road of promoting Chinese traditional culture. Since its birth, the Zhengtu series has been loved by players for its profound cultural heritage and diversified gameplay. In terms of cultural inheritance, the Zhengtu series has always maintained respect and love for traditional Chinese culture, and skillfully integrated traditional cultural elements into the game, bringing more fun and inspiration to players. The CCTV animation "Journey to the West" is a classic that has accompanied the growth of generations.

Win11 Tips Sharing: One trick to skip Microsoft account login Windows 11 is the latest operating system launched by Microsoft, with a new design style and many practical functions. However, for some users, having to log in to their Microsoft account every time they boot up the system can be a bit annoying. If you are one of them, you might as well try the following tips, which will allow you to skip logging in with a Microsoft account and enter the desktop interface directly. First, we need to create a local account in the system to log in instead of a Microsoft account. The advantage of doing this is

Since the official version V1.0 of "Myth of Empire" was launched, it has received enthusiastic attention from many players. The recently launched new big world "Xanadu" has once again attracted a large number of new players to join due to its more balanced server settings, coupled with the Oriental Game Festival's new record low discount of 30% off. At the same time, many players are looking forward to the future development plans of "Myth of Empire". This issue will announce and explain the meteorite armor suit and some tool bench buildings in the Greek Civilization DLC of "Myth of Empire" that everyone is concerned about. The meteorite armor in the Greek Civilization DLC of "Imperial Myth" will also appear in the form of a new recipe. On the basis of continuing to retain the characteristics of civilization and sense of history, a higher-dimensional artistic treatment was carried out. On the one hand, in terms of material matching, it is highlighted through richer golden combinations.

Masters compete with each other and fight to the end! Zhang Weijian enthusiastically endorses the "Swordsman World: Origin" mobile game, a work inherited from the 26-year swordsman relationship in Xishanju, and the cross-server sect competition is now open! With the flash of swords and shadows of swords, heroes emerge in large numbers. The top masters from all servers gather in the cross-server arena to compete for the supreme honor of the first cross-server sect. It is very lively! The sect competition, the moves are full of blood! In the 12 sects of "Swordsman World: Origin" Among them, swords, spears, swords, halberds, fists, palms and sticks all have their own unique moves! For example, the Tang Clan faction used poison-tempered hidden weapons to kill people with one blow; the Five Poisons faction used poisoning techniques to kill people invisibly; the Cuiyan faction used concealed figures to surprise people with swords; the Heavenly King faction used close-quarters hand-to-hand combat to compete... ...There are also hundreds of martial arts secrets such as Yiyangzhi, Lingbo Weibu, and Eighteen Dragon Subduing Palms. The five elements restrain each other, one sect has two routes, and the battle

Go language development mobile application tutorial As the mobile application market continues to boom, more and more developers are beginning to explore how to use Go language to develop mobile applications. As a simple and efficient programming language, Go language has also shown strong potential in mobile application development. This article will introduce in detail how to use Go language to develop mobile applications, and attach specific code examples to help readers get started quickly and start developing their own mobile applications. 1. Preparation Before starting, we need to prepare the development environment and tools. head

On March 3, 2022, less than a month after the birth of the world's first AI programmer Devin, the NLP team of Princeton University developed an open source AI programmer SWE-agent. It leverages the GPT-4 model to automatically resolve issues in GitHub repositories. SWE-agent's performance on the SWE-bench test set is similar to Devin, taking an average of 93 seconds and solving 12.29% of the problems. By interacting with a dedicated terminal, SWE-agent can open and search file contents, use automatic syntax checking, edit specific lines, and write and execute tests. (Note: The above content is a slight adjustment of the original content, but the key information in the original text is retained and does not exceed the specified word limit.) SWE-A
