cocos2dx3.2 往模板build_native.py加入java库脚本

前端之家收集整理的这篇文章主要介绍了cocos2dx3.2 往模板build_native.py加入java库脚本前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

大家有没有试过在导入android项目到eclipse的时候,会报错,说xxx显示红色的东西

这里只要在模板build_native.py 中加入如下:就不需要手到添加java包的引用

具体教程请参考:http://www.cocoachina.com/bbs/3g/read.PHP?tid=199238


def copy_resources(app_android_root):


# remove app_android_root/assets if it exists
assets_dir = os.path.join(app_android_root,"assets")
if os.path.isdir(assets_dir):
shutil.rmtree(assets_dir)


# copy resources
os.mkdir(assets_dir)
resources_dir = os.path.join(app_android_root,"../Resources")
if os.path.isdir(resources_dir):
copy_files(resources_dir,assets_dir)
#--------copy cocos_lib_path start------------
def copy_src_files(src,dst):

for item in os.listdir(src):
path = os.path.join(src,item)

if not item.startswith('.') and os.path.isfile(path):
shutil.copy(path,dst)
if os.path.isdir(path):
new_dst = os.path.join(dst,item)
if not os.path.exists(new_dst):
os.mkdir(new_dst)
copy_src_files(path,new_dst)




def copy_src(app_android_root,cocos_root):

android_src_dir = os.path.join(app_android_root,"src")

cocos_src_path = os.path.join(cocos_root,"cocos/platform/android/java/src”)

if not os.path.exists(android_src_dir) :
os.mkdir(android_src_dir)

if os.path.isdir(cocos_src_path):
copy_src_files(cocos_src_path,android_src_dir)
#--------copy cocos_lib_path end------------


def build(ndk_build_param,android_platform,build_mode):


ndk_root = check_environment_variables()
sdk_root = None
select_toolchain_version()


current_dir = os.path.dirname(os.path.realpath(__file__))
cocos_root = os.path.join(current_dir,"../cocos2d")


app_android_root = current_dir
copy_resources(app_android_root)
#-----------------add copy src ------------
copy_src(app_android_root,cocos_root)

if android_platform is not None:
sdk_root = check_environment_variables_sdk()
if android_platform.isdigit():

android_platform = 'android-'+android_platform

猜你在找的Cocos2d-x相关文章