COCOS2DX 3.x for LUA "Asynchronous load" implementation process

Source: Internet
Author: User

In Lua, the stack created by COCOS2DX can only be accessed by one thread (main thread), and if a child thread is established in C + + and then invoked by C + + to invoke the LUA callback function, asynchronous loading will be an error.

If you attempt to load a resource directly through a C + + child thread, return a Boolean value or the number type notifies LUA to implement the callback, the procedure does not display the problem, but the preempted of the C + + sub-line

The memory address of the resource file is not the same as the memory address of the main line loads the source file, although it has already been loaded, the image resource information already exists in the code memory, but the main thread still cannot access the

Resource memory, so the child line preempted's picture new into a sprite is black.

So LUA can not be implemented by asynchronous loading, only through the implementation of the implementation of a similar asynchronous loading effect, that is (loading a little, the progress bar added a bit),

The code address is as follows Link: https://github.com/caolan/async

COCOS2DX 3.x for LUA "Asynchronous load" implementation process

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.