COCOS2DX LUA Hot Load implementation

Source: Internet
Author: User

"Q" Original 2015-08-30

The company has been using Cocos2dx+lua to develop the game for some time, just as the thermal update of LUA is entrusted to me. Most of the previously hot-updated LUA scripts were loaded after the download. Recent planning and new requirements, need to be in the game process if there is a hot update to remind users, also means that the in-memory LUA files may not be up-to-date. Later http://www.2cto.com/kf/201411/351833.html this blog found that Lua was originally loaded into a package.loaded cache, as long as the corresponding set this to empty and require.

Later also in accordance with the idea of the blog also want to implement a one-click Reload all LUA files, to solve the problem of starting the emulator every time. The overall implementation is possible because of the Mac simulator that the project is using during the development process. The project registers a key event in a major scenario. This time I used the ctrl+r combination to achieve.

Code I also do not post, mainly is the method of the blog, but there are changes,

1, the external library register to add more libraries, such as Protobuf, string, math and so on.

2, for the external library, we do not think that the modification, so the processing of the external library display does not reload.

3, for the framework of files, such as cococs2d files, we think in the development process will not be modified, so in filtering some of this file.

4. Since all LUA files have been reloaded, the corresponding sockets will also be disconnected before.

5. Empty all the memory textures.

In practice, the development is accelerated because there is no need to restart the emulator. Thanks to this blog author for his enthusiastic sharing.

COCOS2DX LUA Hot Load implementation

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.