准备工作:
1. 拷贝cocos2d-x-3.3rc0\external\lua整个文件夹到项目中(如myProject\cocos2d\external\lua)
2. 拷贝cocos2d-x-3.3rc0\cocos\scripting整个文件夹到项目中(如myProject\cocos2d\cocos\scripting)
VS工程配置:
1. 解决方案中添加刚拷贝过来的libluacocos2d项目(添加现有项目: myProject\cocos2d\cocos\scripting\lua-bindings\proj.win32\libluacocos2d.vcxproj)
2. myProject工程添加项目依赖(右键项目属性->添加->引用->添加新引用->勾选libluacocos2d)
3. 附加包含目录添加(参考lua-tests工程):
$(EngineRoot)cocos\scripting\lua-bindings\auto
$(EngineRoot)cocos\scripting\lua-bindings\manual
$(EngineRoot)external\lua\luajit\include
$(EngineRoot)external\lua\tolua
$(EngineRoot)external\lua
4. 连接器->输入添加:
lua51.lib
Android.mk配置:
只需添加:
LOCAL_STATIC_LIBRARIES += cocos2d_lua_static
$(call import-module,scripting/lua-bindings/proj.android)
如:
LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) $(call import-add-path,$(LOCAL_PATH)/../../cocos2d) $(call import-add-path,$(LOCAL_PATH)/../../cocos2d/external) $(call import-add-path,$(LOCAL_PATH)/../../cocos2d/cocos) LOCAL_MODULE := cocos2dcpp_shared LOCAL_MODULE_FILENAME := libcocos2dcpp #====== Auto include all cpp files in Classes directory ====== # define walk function to recursive travel directory define walk $(wildcard $(1)) $(foreach e, $(wildcard $(1)/*), $(call walk, $(e))) endef # travel Classes directory ALLFILES = $(call walk, $(LOCAL_PATH)/../../Classes) FILE_LIST := hellocpp/main.cpp FILE_LIST += $(filter %.cpp, $(ALLFILES)) LOCAL_SRC_FILES := $(FILE_LIST:$(LOCAL_PATH)/%=%) #============================================================= LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes $(LOCAL_PATH)/../../Classes/CCGame/include LOCAL_STATIC_LIBRARIES := cocos2dx_static LOCAL_STATIC_LIBRARIES += cocos2d_lua_static include $(BUILD_SHARED_LIBRARY) $(call import-module,scripting/lua-bindings/proj.android) $(call import-module,.)
时间: 2024-10-14 11:25:22