[COCOS2DX-LUA Script Development 5] Lua uses OOP (in the face of object thinking programming), without binding to create custom Lua class

Source: Internet
Author: User

This site's article is originally written by Li huaming himi. The reposted article must be clearly stated: (Author: Sina Weibo: @ Li huaming himi)
Reproduced from [Black Rice gamedev block] original link: http://www.himigame.com/lua1/1282.html

☞Click to subscribe☜The latest developments in this blog! Notify you of the latest blog in time!


                 

In the previous article, I introduced the tutorials on How to customize the class binding to Lua, so this article will introduce how to create a custom class in Lua using OOP.

First, himi will explain how to customize the Lua class without binding in Lua. In fact, this method has already provided an example for us in the Lua samples of cocos2dx, it depends on whether the children's shoes are carefully read. This example path is in the touchestest in the cocos2d-2.1rc0-x-2.1.2/samples/Lua/testlua under the cocos2dx engine package you decompress, such:

 

In this example, ball. Lua and paddle. Lua are respectively written as objects in Lua. Please take a look at the children's shoes you have not seen.

The following describes how to use Lua to customize the Lua class:

Step 1:

Go to samples/Lua/testlua/resources/luasloud under the cocos2dx Engine Directory and find the "extern. Lua" file. Its content is as follows:

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455

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.