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 |