We recommend that you use pthreadcc. The method has been encapsulated For ease of use, and there is no need to worry about thread concurrency and deadlock issues. During android development
I am familiar with a class called AsyncTask. Today, I encapsulated a similar class to be called by a project developer. The idea is:
Upload a url or pMsg, enable a thread to execute the network request, and notify the main thread to update,
The use of threads is smooth, but when the thread is combined with 2dx, it is found that the OpenGL rendering thread only allows rendering in the main thread, and suddenly think of Android
The same is true. At the beginning, no image in 2dx drawing is displayed.
Later, the thread and CCLayer were encapsulated, which worked well, but the OpengGL rendering was affected. The rendered image was a black box every time,
Color, very depressing.
With some understanding of OpengGL and some experience in mobile game development, I suddenly thought of rendering 2dx first, then executing the thread and modifying the code.
Executed.
Tip: When OpenGL is combined with a thread, You need to load the Sprite you need to render to the memory first. You can set it to not display, and then after the thread is executed
Set the Wizard to display the status to solve the problem that the thread is incompatible with the OpneGL rendering.
:
Before execution, a dialog box is displayed, prompting you to load data. Now the asynchronous loading status is displayed.
<Strong? Http: www.bkjia.com kf ware vc "target =" _ blank "class =" keylink "> VcD4KPHA + tbEg1rTQ0M3quvOjrM2o1qrW98/fs8zatlj80mkjuw.vcd4kpha + pgltzybzcm9 "http://www.bkjia.com/uploadfile/Collfiles/20131223/2013122309500422.jpg" alt = "">