【COCOS2DX-LUA 脚本开发之一】在Cocos2dX游戏中使用Lua脚本进行游戏开发(基础篇并介绍脚本在游戏中详细用途!

http://blog.csdn.net/xiaominghimi/article/details/7464635
转载自【黑米GameDev街区】原文链接:http://www.himigame.com/iphone-cocos2dx/681.html

          ☞ 点击订阅 ☜
博客最新动态!及时将最新博文通知您!

对于游戏公司而言,采用游戏脚本lua、python等进行开发也很常见,但是很多童鞋对脚本并没有很熟悉的概念,本篇则向大家简单介绍脚本的用途以及在Cocos2dx基础用法

Lua和python这些详细介绍的话,请不太熟悉的童鞋自行百度百科哈,那么对于lua和python则是两个常用的脚本语言,lua相对于python而言,lua比较轻量级罢了,而其他区别就不多说了,但是为什么本章要讲解lua的原因则有两点,首先第一:cocos2dx 游戏引擎内嵌lua,第二点:自从“令人愤怒的小鸟”火起来之后,国内很多都偏向于使用lua了=。 =

那么对于脚本的用途这里也大概说两点:

1. 脚本在手游中是类于“大脑”的功能,所有游戏相关的逻辑代码一般都放在脚本中,而客户端(前台)的代码都则属于“肢体”,也可以说是“播放器”,作用只是用户展示出UI界面的功能;那么脚本的作用那么不仅仅如此,比如地图数据等都可以利用脚本使用;

2. 脚本在手机网游中的作用尤为重要,比如一款网游“Himi”没有使用脚本,如果“Himi”1.0版本在发布后突然发现客户端出现一些棘手的bug需要修复,那么你想修改那么也要等待再次更新客户端重新提交发布才可以解决,这样会流失一大批用户,而且游戏每次更新也会流失掉部分用户,这是肯定的;但是如果“Himi”这款网游使用脚本的话,那么解决此类问题很eazy,比如我在“Himi”游戏中的逻辑代码都放在脚本a.lua 中,那么如果a.lua逻辑中哪里出现了问题,我们直接可以将修复后的a.lua脚本更新至服务器中,因为一般脚本都会定义version号,比如a.lua有bug的version:1.0,那么我们修复后的a.lua version改成1.1,当用户每次启动游戏的时候,客户端都会将脚本的version与服务器脚本version做对比,当server端脚本version号比当前脚本新,那么自动下载并覆盖当前脚本,OK,问题解决;不仅仅如此,比如游戏中做个活动呀,换个图片呀等等都可以即使更新,而不是每次修改前端代码都要重新发布新的游戏版本,造成一些损失!

OK,不再多说了,下面我们来介绍在Cocos2dx中对于lua脚本的一些简单使用,首先我们通过新建一个Cocos2dx-lua模版项目,认此模版中有个示例,童鞋们可以直接运行项目看效果,但是大家可能会郁闷在class中完全找不到任何相关的代码?!?那就对了,因为所有逻辑代码都放置在了lua脚本中,项目启动后直接解析的一个名称为hello.lua的脚本!

打开项目的Resources仔细找下,有没有发现有 hello.lua 合hello2.lua两个脚本文件?!OK,就是这里拉。 那么对于cocos2dx_lua demo的例子脚本我这里不多说比较容易,但是肯定不太熟悉的童鞋比较疑惑,那么Himi这里重新整理了一份简单的示例脚本代码,大家可以直接将如下代码直接复制到hello.lua中看效果代码如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
require "hello2" -- 包含hello2这个脚本
-- 注视语句
-- 基本上调用的cocos2dx函数和类的时候就是以cocos2d.*这样子来用
-- 注意2:function 关键字定义函数,end结束函数
-- 打印
cocos2d.ccluaLog( "脚本hello开始运行... " .. myadd(3,5))
-- 创建一个Scene
sceneForWorld = cocos2d.CCScene:node()
-- 创建一个Layer
layerForWorld = cocos2d.cclayer:node()
sceneForWorld:addChild(layerForWorld)
-- 创建一个精灵
spriteForWorld = cocos2d.CCSprite:spriteWithFile( "Icon.png" )
layerForWorld:addChild(spriteForWorld)
-- 获取屏幕宽高
screenSize=cocos2d.CCDirector:sharedDirector():getWinSize()
-- 设置精灵坐标
spriteForWorld:setPosition(cocos2d.CCPoint(screenSize.width*0.5,screenSize.height*0.5))
-- 设置精灵缩放2倍
spriteForWorld:setScale(2)
-- 添加一个cclabelTTF (!!!!!!备注!!!!!!)
myLableTTF =cocos2d.cclabelTTF:labelWithString( "Himi- Lua 基础" , "Helvetica-Bold" ottom:0px!important; margin-left:0px!important; padding-top:0px!important; padding-right:0px!important; padding-bottom:0px!important; padding-left:0px!important; border-top-width:0px!important; border-right-width:0px!important; border-bottom-width:0px!important; border-left-width:0px!important; border-style:initial; border-color:initial; font-weight:normal!important; font-style:normal!important; font-size:1em!important; font-family:Consolas,24)
myLableTTF:setPosition(cocos2d.CCPoint(screenSize.width*0.5,screenSize.height*0.5+100))
sceneForWorld:addChild(myLableTTF)
-- 添加一个cclabelTTF
myLableTTF2 =cocos2d.cclabelTTF:labelWithString( "上面icon跟随用户触屏位置" ottom:0px!important; margin-left:0px!important; padding-top:0px!important; padding-right:0px!important; padding-bottom:0px!important; padding-left:0px!important; border-top-width:0px!important; border-right-width:0px!important; border-bottom-width:0px!important; border-left-width:0px!important; border-style:initial; border-color:initial; font-weight:normal!important; font-style:normal!important; font-size:1em!important; font-family:Consolas,24)
myLableTTF2:setPosition(cocos2d.CCPoint(screenSize.width*0.5,screenSize.height*0.5-100))
sceneForWorld:addChild(myLableTTF2)
-- @@@@@@@@@@触摸事件
--开启触摸
layerForWorld:setIsTouchEnabled( true )
-- 注册触摸事件
layerForWorld.__CCTouchDelegate__:registerScriptTouchHandler(cocos2d.CCTOUCHBEGAN,Fixed; background-color:initial!important; border-style:initial!important; border-color:initial!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; outline-width:0px!important; outline-style:initial!important; outline-color:initial!important; overflow-x:visible!important; overflow-y:visible!important; position:static!important; right:auto!important; text-align:left!important; top:auto!important; width:auto!important; min-height:inherit!important; color:blue!important">"btnTouchBegin" )
layerForWorld.__CCTouchDelegate__:registerScriptTouchHandler(cocos2d.CCTOUCHMOVED,Fixed; background-color:initial!important; border-style:initial!important; border-color:initial!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; outline-width:0px!important; outline-style:initial!important; outline-color:initial!important; overflow-x:visible!important; overflow-y:visible!important; position:static!important; right:auto!important; text-align:left!important; top:auto!important; width:auto!important; min-height:inherit!important; color:blue!important">"btnTouchMove" )
layerForWorld.__CCTouchDelegate__:registerScriptTouchHandler(cocos2d.CCTOUCHENDED,Fixed; background-color:initial!important; border-style:initial!important; border-color:initial!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; outline-width:0px!important; outline-style:initial!important; outline-color:initial!important; overflow-x:visible!important; overflow-y:visible!important; position:static!important; right:auto!important; text-align:left!important; top:auto!important; width:auto!important; min-height:inherit!important; color:blue!important">"btnTouchEnd" )
-- touch handers
pointBegin = nil
function btnTouchBegin(e)
)
local v = e[1]
local pointMove = v:locationInView(v:view())
pointMove = cocos2d.CCDirector:sharedDirector():convertToGL(pointMove)
spriteForWorld:setPosition(cocos2d.CCPoint(pointMove.x,pointMove.y))
end
function btnTouchMove(e)
)
local v = e[1]
local pointMove = v:locationInView(v:view())
pointMove = cocos2d.CCDirector:sharedDirector():convertToGL(pointMove)
ottom:0px!important; margin-left:0px!important; padding-top:0px!important; padding-right:1em!important; padding-bottom:0px!important; padding-left:1em!important; border-top-width:0px!important; border-right-width:0px!important; border-bottom-width:0px!important; border-left-width:0px!important; border-style:initial; border-color:initial; font-weight:normal!important; font-style:normal!important; font-size:1em!important; font-family:Consolas,pointMove.y))
end
function btnTouchEnd(e)
)
end
-- @@@@@@@@@@触摸结束
--动态小狗
winSize = cocos2d.CCDirector:sharedDirector():getWinSize()
FrameWidth = 105
FrameHeight = 95
textureDog = cocos2d.CCTextureCache:sharedTextureCache():addImage( "dog.png" )
frame0 = cocos2d.CCSpriteFrame:frameWithTexture(textureDog,cocos2d.CCRectMake(0,FrameWidth,FrameHeight))
frame1 = cocos2d.CCSpriteFrame:frameWithTexture(textureDog,cocos2d.CCRectMake(FrameWidth*1,FrameHeight))
spriteDog = cocos2d.CCSprite:spriteWithSpriteFrame(frame0)
spriteDog:setPosition(cocos2d.CCPoint(100,winSize.height/4*3))
layerForWorld:addChild(spriteDog)
animFrames = cocos2d.CCMutableArray_CCSpriteFrame__: new (2)
animFrames:addobject(frame0)
animFrames:addobject(frame1)
animation = cocos2d.CCAnimation:animationWithFrames(animFrames,0.5)
animate = cocos2d.CCAnimate:actionWithAnimation(animation, false );
spriteDog:runAction(cocos2d.CCRepeatForever:actionWithAction(animate))
function prForHimi()
"reFresh function" )
--取消选择器
--cocos2d.CCScheduler:sharedScheduler():unscheduleScriptFunc( "prForHimi" )
end
--使用选择器进行函数更新
--cocos2d.CCScheduler:sharedScheduler():scheduleScriptFunc( )
--循环语句
for i=0,4,1 do
j=0,2 do
"for loop" ottom:0px!important; margin-left:0px!important; padding-top:0px!important; padding-right:0px!important; padding-bottom:0px!important; padding-left:0px!important; border-top-width:0px!important; border-right-width:0px!important; border-bottom-width:0px!important; border-left-width:0px!important; border-style:initial; border-color:initial; font-weight:normal!important; font-style:normal!important; font-size:1em!important; font-family:Consolas,i)
end
end
-- 避免内存泄漏
collectgarbage( "setpause" ottom:0px!important; margin-left:0px!important; padding-top:0px!important; padding-right:0px!important; padding-bottom:0px!important; padding-left:0px!important; border-top-width:0px!important; border-right-width:0px!important; border-bottom-width:0px!important; border-left-width:0px!important; border-style:initial; border-color:initial; font-weight:normal!important; font-style:normal!important; font-size:1em!important; font-family:Consolas,100)
"setstepmul" ottom:0px!important; margin-left:0px!important; padding-top:0px!important; padding-right:0px!important; padding-bottom:0px!important; padding-left:0px!important; border-top-width:0px!important; border-right-width:0px!important; border-bottom-width:0px!important; border-left-width:0px!important; border-style:initial; border-color:initial; font-weight:normal!important; font-style:normal!important; font-size:1em!important; font-family:Consolas,5000)
-- 播放背景音乐
--CocosDenshion.SimpleAudioEngine:sharedEngine():playBackgroundMusic( "background.mp3" )
--CocosDenshion.SimpleAudioEngine:sharedEngine():preloadEffect( "effect1.wav" )
-- run整个scene
cocos2d.CCDirector:sharedDirector():runWithScene(sceneForWorld)
"脚本hello正常执行结束... " ottom:0px!important; margin-left:0px!important; padding-top:0px!important; padding-right:0px!important; padding-bottom:0px!important; padding-left:0px!important; border-top-width:0px!important; border-right-width:0px!important; border-bottom-width:0px!important; border-left-width:0px!important; border-style:initial; border-color:initial; font-weight:normal!important; font-style:normal!important; font-size:1em!important; font-family:Consolas,5))

运行效果图如下:

对于Himi上面给出的自己修改后的代码注视写的狠清楚了 =。 = 所以不多加赘述,但是Himi这里需要还要详细说一点;

脚本lua等一般都示通过中间层(解析)进行与前端代码(Cocos2dX封装的引擎类库)交互,所以很多方法名称可能发生了改变,那么对于不太熟悉的童鞋我们如何下手?

OK,如刚才的代码中有个“备注”,不知道细心童鞋们看到没有,这里是添加一个cclabelTTF ,假如我们不知道它的构造函数是否有修改,或者说参数忘记都是什么了,那么请打开你项目的libs文件夹,然后打开lua文件夹,继续打开cocos2dx_support文件夹找到 LuaCocos2d.cpp文件打开,(注意这个文件代码很多,打开较慢)然后你会看到很多方法的定义与实现!

那么假如我们来找 cclabelTTF的构造方法,那么搜一下如下语句:

1
tolua_beginmodule(tolua_S,Fixed; background-color:initial!important; border-style:initial!important; border-color:initial!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; outline-width:0px!important; outline-style:initial!important; outline-color:initial!important; overflow-x:visible!important; overflow-y:visible!important; position:static!important; right:auto!important; text-align:left!important; top:auto!important; width:auto!important; min-height:inherit!important; color:blue!important">"cclabelTTF" );

你将发现此类下方一大批类似的代码:

没错这里就是此类的所有是lua-cocos2dx之间的转换函数定义,比如常用的cclabelTTF构造函数

tolua_function(tolua_S,Fixed; background-color:initial!important; border-style:initial!important; border-color:initial!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; outline-width:0px!important; outline-style:initial!important; outline-color:initial!important; overflow-x:visible!important; overflow-y:visible!important; position:static!important; right:auto!important; text-align:left!important; top:auto!important; width:auto!important; min-height:inherit!important; color:blue!important">"labelWithString" ottom:0px!important; margin-left:0px!important; padding-top:0px!important; padding-right:0px!important; padding-bottom:0px!important; padding-left:0px!important; border-top-width:0px!important; border-right-width:0px!important; border-bottom-width:0px!important; border-left-width:0px!important; border-style:initial; border-color:initial; font-weight:normal!important; font-style:normal!important; font-size:1em!important; font-family:Consolas,tolua_Cocos2d_cocos2d_cclabelTTF_labelWithString01);

函数第一参数大家不用理会,第二个参数表示我们使用cocos2d/x时调用函数名称,后面则是lua-cocos2dx之间的转换函数实现代码,大家可以继续搜索第三个参数或者按住command然后点击第三个参数找到其函数实现代码

28
/* method: labelWithString of class cocos2d::cclabelTTF */
#ifndef TOLUA_disABLE_tolua_Cocos2d_cocos2d_cclabelTTF_labelWithString01
static int tolua_Cocos2d_cocos2d_cclabelTTF_labelWithString01(lua_State* tolua_S)
{
tolua_Error tolua_err;
if (
!tolua_isusertable(tolua_S,Fixed; background-color:initial!important; border-style:initial!important; border-color:initial!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; outline-width:0px!important; outline-style:initial!important; outline-color:initial!important; overflow-x:visible!important; overflow-y:visible!important; position:static!important; right:auto!important; text-align:left!important; top:auto!important; width:auto!important; min-height:inherit!important; color:blue!important">"cocos2d::cclabelTTF" ottom:0px!important; margin-left:0px!important; padding-top:0px!important; padding-right:0px!important; padding-bottom:0px!important; padding-left:0px!important; border-top-width:0px!important; border-right-width:0px!important; border-bottom-width:0px!important; border-left-width:0px!important; border-style:initial; border-color:initial; font-weight:normal!important; font-style:normal!important; font-size:1em!important; font-family:Consolas,&tolua_err) ||
!tolua_isstring(tolua_S,2,&tolua_err) ||
ottom:0px!important; margin-left:0px!important; padding-top:0px!important; padding-right:1em!important; padding-bottom:0px!important; padding-left:1em!important; border-top-width:0px!important; border-right-width:0px!important; border-bottom-width:0px!important; border-left-width:0px!important; border-style:initial; border-color:initial; font-weight:normal!important; font-style:normal!important; font-size:1em!important; font-family:Consolas,3,&tolua_err) ||
!tolua_isnumber(tolua_S,&tolua_err) ||
!tolua_isnoobj(tolua_S,5,&tolua_err)
)
goto tolua_lerror;
else
{
const char * label = (( *) tolua_tostring(tolua_S,0));
* fontName = (( ottom:0px!important; margin-left:0px!important; padding-top:0px!important; padding-right:0px!important; padding-bottom:0px!important; padding-left:0px!important; border-top-width:0px!important; border-right-width:0px!important; border-bottom-width:0px!important; border-left-width:0px!important; border-style:initial; border-color:initial; font-weight:bold!important; font-style:normal!important; font-size:1em!important; font-family:Consolas,0));
float fontSize = (( ) tolua_tonumber(tolua_S,0));
{
cocos2d::cclabelTTF* tolua_ret = (cocos2d::cclabelTTF*) cocos2d::cclabelTTF::labelWithString(label,fontName,fontSize);
tolua_pushusertype(tolua_S,( void *)tolua_ret,Fixed; background-color:initial!important; border-style:initial!important; border-color:initial!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; outline-width:0px!important; outline-style:initial!important; outline-color:initial!important; overflow-x:visible!important; overflow-y:visible!important; position:static!important; right:auto!important; text-align:left!important; top:auto!important; width:auto!important; min-height:inherit!important; color:black!important">);
}
}
return 1;
tolua_lerror:
tolua_Cocos2d_cocos2d_cclabelTTF_labelWithString00(tolua_S);
}
#endif //#ifndef TOLUA_disABLE

在这里看到此函数转换过程,并可以很清楚看到:

ottom:0px!important; margin-left:0px!important; padding-top:0px!important; padding-right:0px!important; padding-bottom:0px!important; padding-left:0px!important; border-top-width:0px!important; border-right-width:0px!important; border-bottom-width:0px!important; border-left-width:0px!important; border-style:initial; border-color:initial; font-weight:normal!important; font-style:normal!important; font-size:1em!important; font-family:Consolas,fontSize);

到这里大家会很清楚需要的参数都是哪些,如果还不清楚,继续按住Command然后点击labelWithString进入cocos2dx引擎代码cclabelTTF.cpp中的此函数实现啦!

可能这部分有童鞋看得比较迷茫 =。 = 那么Himi来简化这些复杂来说:

解析lua脚本中的一句代码->通过解析层代码->将其转换并转到前端代码进行使用

那么当然此过程也可逆:

前端代码->通过解析层代码->使用lua脚本中小编

这里由于Himi对cocos2dx 中的lua还没有深入了解,所以不知是否过程可逆;

OK,基本就是这样,对于脚本的熟悉,主要还是在公司进行使用然后慢慢熟悉和熟练掌握的,本章主要需要童鞋们记住的是脚本的概念和作用!

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


    本文实践自 RayWenderlich、Ali Hafizji 的文章《How To Create Dynamic Textures with CCRenderTexture in Cocos2D 2.X》,文中使用Cocos2D,我在这里使用Cocos2D-x 2.1.4进行学习和移植。在这篇文章,将会学习到如何创建实时纹理、如何用Gimp创建无缝拼接纹
Cocos-code-ide使用入门学习地点:杭州滨江邮箱:appdevzw@163.com微信公众号:HopToad 欢迎转载,转载标注出处:http://blog.csdn.netotbaron/article/details/424343991.  软件准备 下载地址:http://cn.cocos2d-x.org/download 2.  简介2.1         引用C
第一次開始用手游引擎挺激动!!!进入正题。下载资源1:从Cocos2D-x官网上下载,进入网页http://www.cocos2d-x.org/download,点击Cocos2d-x以下的Download  v3.0,保存到自定义的文件夹2:从python官网上下载。进入网页https://www.python.org/downloads/,我当前下载的是3.4.0(当前最新
    Cocos2d-x是一款强大的基于OpenGLES的跨平台游戏开发引擎,易学易用,支持多种智能移动平台。官网地址:http://cocos2d-x.org/当前版本:2.0    有很多的学习资料,在这里我只做为自己的笔记记录下来,错误之处还请指出。在VisualStudio2008平台的编译:1.下载当前稳
1.  来源 QuickV3sample项目中的2048样例游戏,以及最近《最强大脑》娱乐节目。将2048改造成一款挑战玩家对数字记忆的小游戏。邮箱:appdevzw@163.com微信公众号:HopToadAPK下载地址:http://download.csdn.net/detailotbaron/8446223源码下载地址:http://download.csdn.net/
   Cocos2d-x3.x已经支持使用CMake来进行构建了,这里尝试以QtCreatorIDE来进行CMake构建。Cocos2d-x3.X地址:https://github.com/cocos2d/cocos2d-x1.打开QtCreator,菜单栏→"打开文件或项目...",打开cocos2d-x目录下的CMakeLists.txt文件;2.弹出CMake向导,如下图所示:设置
 下载地址:链接:https://pan.baidu.com/s/1IkQsMU6NoERAAQLcCUMcXQ提取码:p1pb下载完成后,解压进入build目录使用vs2013打开工程设置平台工具集,打开设置界面设置: 点击开始编译等待编译结束编译成功在build文件下会出现一个新文件夹Debug.win32,里面就是编译
分享一下我老师大神的人工智能教程吧。零基础!通俗易懂!风趣幽默!还带黄段子!希望你也加入到我们人工智能的队伍中来!http://www.captainbed.net前言上次用象棋演示了cocos2dx的基本用法,但是对cocos2dx并没有作深入的讨论,这次以超级马里奥的源代码为线索,我们一起来学习超级马里奥的实
1. 圆形音量button事实上作者的本意应该是叫做“电位计button”。可是我觉得它和我们的圆形音量button非常像,所以就这么叫它吧~先看效果:好了,不多解释,本篇到此为止。(旁白: 噗。就这样结束了?)啊才怪~我们来看看代码:[cpp] viewplaincopyprint?CCContro
原文链接:http://www.cnblogs.com/physwf/archive/2013/04/26/3043912.html为了进一步深入学习贯彻Cocos2d,我们将自己写一个场景类,但我们不会走的太远,凡是都要循序渐进,哪怕只前进一点点,那也至少是前进了,总比贪多嚼不烂一头雾水的好。在上一节中我们建
2019独角兽企业重金招聘Python工程师标准>>>cocos2d2.0之后加入了一种九宫格的实现,主要作用是用来拉伸图片,这样的好处在于保留图片四个角不变形的同时,对图片中间部分进行拉伸,来满足一些控件的自适应(PS: 比如包括按钮,对话框,最直观的形象就是ios里的短信气泡了),这就要求图
原文链接:http://www.cnblogs.com/linji/p/3599478.html1.环境和工具准备Win7VS2010/2012,至于2008v2版本之后似乎就不支持了。 2.安装pythonv.2.0版本之前是用vs模板创建工程的,到vs2.2之后就改用python创建了。到python官网下载版本2.7.5的,然后
环境:ubuntu14.04adt-bundle-linux-x86_64android-ndk-r9d-linux-x86_64cocos2d-x-3.0正式版apache-ant1.9.3python2.7(ubuntu自带)加入环境变量exportANDROID_SDK_ROOT=/home/yangming/adt-bundle-linux/sdkexportPATH=${PATH}:/$ANDROID_SDK_ROOTools/export
1开发背景游戏程序设计涉及了学科中的各个方面,鉴于目的在于学习与进步,本游戏《FlappyBird》采用了两个不同的开发方式来开发本款游戏,一类直接采用win32底层API来实现,另一类采用当前火热的cocos2d-x游戏引擎来开发本游戏。2需求分析2.1数据分析本项目要开发的是一款游
原文链接:http://www.cnblogs.com/linji/p/3599912.html//纯色色块控件(锚点默认左下角)CCLayerColor*ccc=CCLayerColor::create(ccc4(255,0,0,128),200,100);//渐变色块控件CCLayerGradient*ccc=CCLayerGradient::create(ccc4(255,0,0,
原文链接:http://www.cnblogs.com/linji/p/3599488.html//载入一张图片CCSprite*leftDoor=CCSprite::create("loading/door.png");leftDoor->setAnchorPoint(ccp(1,0.5));//设置锚点为右边中心点leftDoor->setPosition(ccp(240,160));/
为了答谢广大学员对智捷课堂以及关老师的支持,现购买51CTO学院关老师的Cocos2d-x课程之一可以送智捷课堂编写图书一本(专题可以送3本)。一、Cocos2d-x课程列表:1、Cocos2d-x入门与提高视频教程__Part22、Cocos2d-x数据持久化与网络通信__Part33、Cocos2d-x架构设计与性能优化内存优
Spawn让多个action同时执行。Spawn有多种不同的create方法,最终都调用了createWithTwoActions(FiniteTimeAction*action1,FiniteTimeAction*action2)方法。createWithTwoActions调用initWithTwoActions方法:对两个action变量初始化:_one=action1;_two=action2;如果两个a
需要环境:php,luajit.昨天在cygwin上安装php和luajit环境,这真特么是一个坑。建议不要用虚拟环境安装打包环境,否则可能会出现各种莫名问题。折腾了一下午,最终将环境转向linux。其中,luajit的安装脚本已经在quick-cocos2d-x-develop/bin/中,直接luajit_install.sh即可。我的lin
v3.0相对v2.2来说,最引人注意的。应该是对触摸层级的优化。和lambda回调函数的引入(嗯嗯,不枉我改了那么多类名。话说,每次cocos2dx大更新。总要改掉一堆类名函数名)。这些特性应该有不少人研究了,所以今天说点跟图片有关的东西。v3.0在载入图片方面也有了非常大改变,仅仅只是