quick-3.5 Lua calls C + +

Source: Internet
Author: User

1. Generate Holo.cpp and Holo.h files, specific implementation omitted ... (Holo the name can be changed)


2. In the Cocos folder in the quick-3.5 directory, create a new My folder (my can change the name), and then put the. cpp and. h files in the quick-3.5/cocos/my


3. Enter Quick-3.5/tools/tolua folder, copy cocos2dx_csloader.ini file name My_holo.ini and then modify My_holo The . INI is as follows:

[My_holo]
# The prefix to being added to the generated functions. You might or might is not the use of this in your own
# templates
prefix =My_holo
# Create a target namespace (in JavaScript, this would create some code like the equiv. to ' NS = NS | | {}`)
# All classes'll be embedded on that namespace
Target_namespace = CC
Android_headers =-i% (androidndkdir) s/platforms/android-14/arch-arm/usr/include-i% (androidndkdir) s/sources/ cxx-stl/gnu-libstdc++/4.7/libs/armeabi-v7a/include-i% (Androidndkdir) s/sources/cxx-stl/gnu-libstdc++/4.7/ include-i% (Androidndkdir) s/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a/include-i% (androidndkdir) s/ Sources/cxx-stl/gnu-libstdc++/4.8/include
Android_flags =-d_size_t_defined_
Clang_headers =-i% (clangllvmdir) s/lib/clang/3.3/include
Clang_flags =-nostdinc-x C + +-std=c++11-u __sse__
Cocos_headers =-i% (cocosdir) s/cocos-i% (cocosdir) s/cocos/platform/android
Cocos_flags =-dandroid
Cxxgenerator_headers =
# Extra arguments for clang
extra_arguments =% (android_headers) s% (clang_headers) s% (cxxgenerator_headers) s% (cocos_headers) s% (android_flags) s % (clang_flags) s% (cocos_flags) s% (extra_flags) s
# What headers to parse
headers =% (Cocosdir) s/cocos/my/holo.h
# What classes to produce code for. You can use the regular expressions here. When testing the regular
# expression, it'll be enclosed in "^$", like this: "^menu*$".
Classes =Holo.*
# What should we skip? In the format classname::[function function]
# ClassName is a regular expression, but would be used like this: "^classname$" functions was also
# Regular expressions, they won't is surrounded by "^$". If you want to skip a whole class, just
# Add a single "*" as functions. See bellow for several examples. A Special class name is "*", which
# would apply to all class names. This was a convenience wildcard to being able to skip similar named
# Functions from all classes.
Skip =
Rename_functions =
Rename_classes =
# for all class names, should we remove something when registering in the target VM?
Remove_prefix =
# classes for which there'll be no "parent" lookup
Classes_have_no_parents =
# base classes which'll be skipped when their sub-classes found them.
Base_classes_to_skip = clonable
# classes that create no constructor
# Set is special and we'll use a Hand-written constructor
Abstract_classes =
# Determining whether to use Script object (JS object) to control the lifecycle of Native (CPP) object or the other-the-same-to-do Arou nd. Supported values are ' yes ' or ' no '.
Script_control_cpp = No


4. Modify the genbindings.py file to insert between lines 136-150 lines: 'my_holo. Ini ': ('my_holo', ' Lua_My_holo_ Auto '), \


5. Open the terminal, the CD to the Quick-3.5/tools/tolua folder to run./genbindings.py, the compilation succeeds in lua_my_holo_auto. cpp and Lua_ are generated under the Quick-3.5/cocos/scripting/lua-bindings/auto directory my_holo_auto. HPP


6. Go to Quick-3.5/tools/simulator/frameworks/runtime-src/proj.ios_mac directory, open simulator.xcodeproj with Xcode, click on the left directory structure,

in cocos2d_lua_bindings.xcodeproj directory right click on Auto Directory Select Add Fileds to " cocos2d_lua_bindings.xcodeproj " lua_ my_holo _auto .cpp and lua_ my_holo _auto .hpp

Click cocos2d_libs.xcodeproj Directory Add fileds to "cocos2d_libs.xcodeproj", add my Folder


7. Go to the Classes folder, open the Lua_module_register.h file, add # include "lua_my_holo_auto. hpp "header file, add Register_all_my_holo (L) under the Lua_module_register method;


8. In Xcode Select Simulator Mac to recompile the MAC Emulator (note: 1-8 steps just change the simulator, 9 steps is to change the project)


9. Select your project (if the project name is:Mydemo), according to the above method,

change the Quick-3.5/tools/tolua into a Mydemo/frameworks/cocos2d-x/tools/tolua .

Change the quick-3.5/cocos/scripting/lua-bindings/auto into mydemo/ Frameworks/cocos2d-x/cocos/scripting/lua-bindings/auto

Change the Quick-3.5/tools/simulator/frameworks/runtime-src/proj.ios_mac into Mydemo /frameworks/runtime-src/proj.ios_mac

Hit mydemo.xcodeproj, follow the above 1-7 to redo it again.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

quick-3.5 Lua calls C + +

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.