Home Database Mysql Tutorial 网游中一个技巧

网游中一个技巧

Jun 07, 2016 pm 03:00 PM
client develop us Skill online games Online game

当我们在开发网络游戏客户端时经常会(肯定会)开一个线程负责接收,发送网络消息,这时我们必然会碰到一些问题如: 在一些对战列表中随时有玩家上下线,这时我们应该会涉及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;
}

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Two Point Museum: All Exhibits And Where To Find Them
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

'Elsword' Lydia's third branch opens, crazy researcher comes online 'Elsword' Lydia's third branch opens, crazy researcher comes online Apr 24, 2024 pm 02:25 PM

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

Four recommended AI-assisted programming tools Four recommended AI-assisted programming tools Apr 22, 2024 pm 05:34 PM

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

Zhengtu IPx classic animation 'Journey to the West' The journey to the west is fearless and fearless Zhengtu IPx classic animation 'Journey to the West' The journey to the west is fearless and fearless Jun 10, 2024 pm 06:15 PM

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: Skip Microsoft Account Login with One Trick Win11 Tips Sharing: Skip Microsoft Account Login with One Trick Mar 27, 2024 pm 02:57 PM

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

'Imperial Myth' Greek Civilization DLC Meteor Armor and Furnace Original Art Revealed 'Imperial Myth' Greek Civilization DLC Meteor Armor and Furnace Original Art Revealed Apr 26, 2024 pm 05:43 PM

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.

The martial arts PK is greatly upgraded! 'World of Swordsman: Origin' cross-server sect competition launched The martial arts PK is greatly upgraded! 'World of Swordsman: Origin' cross-server sect competition launched Mar 30, 2024 am 11:36 AM

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

Learn how to develop mobile applications using Go language Learn how to develop mobile applications using Go language Mar 28, 2024 pm 10:00 PM

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

Which AI programmer is the best? Explore the potential of Devin, Tongyi Lingma and SWE-agent Which AI programmer is the best? Explore the potential of Devin, Tongyi Lingma and SWE-agent Apr 07, 2024 am 09:10 AM

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

See all articles