APP下载

基于Lua动态脚本语言Cocos2d—x应用开发的技术研究

2015-05-30马超马佳琳

软件工程 2015年8期

马超 马佳琳

摘 要:Lua脚本语言技术给Coco2d-x开发,带来了新的天地。通过Lua脚本语言开发Cocos2d-x应用,摆脱了C/C++开发的繁琐代码,使得开发变得快速高效又能同时在多个平台运行,Lua脚本语言的可拓展性,可以使它很好的集成在应用程序中。同时Lua语言在开发成为控制器。控制应用程序的逻辑而Coco2d-x之提供显示功能和跨平台功能。这样开发不仅可以动态修改客户端BUG,而且还能动态更新应用内容避免了更新带来的客户流失。Lua语言免费、小巧、快速易移植降低了开发成本又保证了应用性能。

关键词:Coco2d-x;动态更新;Lua;跨平台开发

中图分类号:TP368.1 文献标识码:A

Abstract:The Lua scripting language technology has brought the new heaven and earth for the development of Coco2d-x.Through the Lua scripting language development Cocos2d-x application,get rid of the tedious code of C/C++ development,makes the development of fast and efficient and can run on multiple platforms at the same time,the Lua scripting language can expand sex,can make it a good integration in the application.At the same time the Lua language become controller in development.Control the application logic and Coco2d-providing display functions of x and cross-platform features.Such development can dynamically modify the client not only bugs,but also dynamic update application content to avoid the update of customer churn.Free,small,fast,easy to transplant the Lua language reduces the development cost and guarantee the application performance.

Keywords:Cocos2d-x;dynamic updating;Lua;cross-platform development

1 引言(Introduction)

Cocos2d-x是基于C++语言的移动端应用程序开发的开源框架。Cocos2d-iPhone项目的C++版本[1]。Cocos2d-x开发框架用C++语言重写了Cocos2d开发框架从而实现应用开发跨平台,在跨平台移动端应用开发中Cocos2d-x框架被大量使用[2]。其开发的手机应用,可以在C++或者Lua中编写。Cocos2d-x项目能够兼容iOS操作系统,Android操作系统,黑莓Blackberry操作系统等。在PC端Cocos2d-x开发框架支持的操作系统包括Linux操作系统、Mac操作系统和Windows操作系统等PC端操作系统,因此,Cocos2d-x能够在PC端操作系统中可以进行编辑和调试使得其在开发中变得高效快捷[3]。

2 基于Lua动态脚本语言Coco2d-x应用开发的关键技术(The key technology of Cocos2d-x application development based on the dynamic scripting language Lua)

(1)Lua技术

Lua是一个小巧的动态语言。Lua动态语言的设计初衷,为应用程序开发提供订制功能与灵活的拓展。作为脚本语言它具有轻量、可拓展、简洁等特点[4]。因为C++语言与Lua脚本语言具有良好交互能力。可以复杂繁琐的C++开发变为简单快捷的Lua语言开发。

(2)Lua与C++交……

登录APP查看全文