创建项目: For(MAC)

Runtime Requirements

  • Android 2.3 or newer
  • iOS 5.0 or newer
  • OS X 10.7 or newer
  • Windows 7 or newer
  • Linux Ubuntu 12.04 (or newer)
  • cocos2d-x v3.0rc(or newer)

Software
Requirements

  • Xcode 4.6 (for iOS or Mac)
  • gcc 4.7 for Linux or Android. For Android ndk-r9 or newer is required.
  • Visual Studio 2012 (for Windows)
  • Python 2.7.5

Create
A New Project

$ cd cocos2d-x
$ ./setup.py
$ source ~/.bash_profile # may be ~/.bash_login or ~/.profile, depends on your environemnt
$ cocos new MyGame -p com.MyCompany.MyGame -l cpp -d ~/MyCompany
  • MyGame: name of your project
  • -p com.MyCompany.MyGame: package name for android
  • -l cpp: programming language used for the project, valid
    value is cppand lua
  • -d ~/MyCompany: directory to hold your project

Folder structure of the generated project is as following:

(Note: The directory may be different when the project type is lua.)

Build
And Run New Project

$ cocos run -s ~/MyCompany/MyGame -p ios
  • -s: directory of the new project. This could be an absolute
    path or a relative path.
  • -p: which platform to run on. Options are ios,android,win32,mac and linux.

(Note: You are a tmux user, you should add reattach-to-user-namespace before
the command cocos. For more information, please refer to this
link
 for more information.)

You can run cocos run --help for more detail information.


体验变化:

1、以CC开头的类从此去掉CC。如:

?
1
2
3
4
5
<code>|
v2.
1      

| v3.
0    

|
|
CCSprite   | Sprite   |
|
CCNode     | Node     |
|
CCDirector | Director |
|
etc...                |</code>

举个样例,创建一个精灵的方式:

1
2
3
4
5
6
v2.0
CCSprite*
sp = CCSprite::create();
 
 
v3.0
auto
sp = Sprite::create();

2、clone() 替代 copy(), 这个我用的不多。所以也就不多交代了;





3、Director的单例换成getInstance() 和 destroyInstance();

1
2
3
4
<code>|
v2.
1                         

| v3.
0                       

|
|
CCDirector->sharedDirector()  | Director->getInstance()     |
|
CCDirector->endDirector()     | Director->destroyInstance() |
|
etc...                                                      |</code>

|

4、新的触摸机制,先贴一段代码给大家看看,可能是下一篇或者下下篇我会具体讲下新的触摸机制的。(嘻嘻。搞得我好像非常牛逼哄哄的样子)

1
2
3
4
5
6
7
8
9
10
11
12
auto
sprite = Sprite::create(
"file.png");
...
auto
listener = EventListenerTouchOneByOne::create();
listener->setSwallowTouch(true);
listener->onTouchBegan    
= [](Touch* touch, Event* event) { do_some_thing(); 
return

true

};
listener->onTouchMoved    
= [](Touch* touch, Event* event) { do_some_thing();  };
listener->onTouchEnded    
= [](Touch* touch, Event* event) { do_some_thing();  };
listener->onTouchCancelled
= [](Touch* touch, Event* event) { do_some_thing();  };
//
The priority of the touch listener is based on the draw order of sprite
EventDispatcher::getInstance()->addEventListenerWithSceneGraphPriority(listener,
sprite);
//
Or the priority of the touch listener is a fixed value
EventDispatcher::getInstance()->addEventListenerWithFixedPriority(listener,
100);
//
100 is a fixed value

5、另一些杂七杂八的东西,本人理解的不透。也就不发出来献丑了。最后将CCType.h 里的一些变动贴出来,让我们愉快的结束这篇博文。

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<code>|
v2.
1

struct names | v3.
0

struct names |
|
ccColor3B         | Color3B |
|
ccColor4B         | Color4B |
|
ccColor4F         | Color4F |
|
ccVertex2F        | Vertex2F |
|
ccVertex3F        | Vertex3F |
|
ccTex2F           | Tex2F |
|
ccPointSprite     | PointSprite |
|
ccQuad2           | Quad2 |
|
ccQuad3           | Quad3 |
|
ccV2F_C4B_T2F     | V2F_C4B_T2F |
|
ccV2F_C4F_T2F     | V2F_C4F_T2F |
|
ccV3F_C4B_T2F     | V3F_C4B_T2F |
|
ccV2F_C4B_T2F_Triangle | V2F_C4B_T2F_Triangle |
|
ccV2F_C4B_T2F_Quad | V2F_C4B_T2F_Quad |
|
ccV3F_C4B_T2F_Quad | V3F_C4B_T2F_Quad |
|
ccV2F_C4F_T2F_Quad | V2F_C4F_T2F_Quad |
|
ccBlendFunc       | BlendFunc |
|
ccT2F_Quad        | T2F_Quad |
|
ccAnimationFrameData | AnimationFrameData |
</code>

一些全局的定义:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
//
in v2.1
ccColor3B
color3B = ccc3(
0,
0,
0);
ccc3BEqual(color3B,
ccc3(
1,
1,
1));
ccColor4B
color4B = ccc4(
0,
0,
0,
0);
ccColor4F
color4F = ccc4f(
0,
0,
0,
0);
color4F
= ccc4FFromccc3B(color3B);
color4F
= ccc4FFromccc4B(color4B);
ccc4FEqual(color4F,
ccc4F(
1,
1,
1,
1));
color4B
= ccc4BFromccc4F(color4F);
 
color3B
= ccWHITE;
 
//
in v3.0
Color3B
color3B = Color3B(
0,
0,
0);
color3B.equals(Color3B(1,
1,
1));
Color4B
color4B = Color4B(
0,
0,
0,
0);
Color4F
color4F = Color4F(
0,
0,
0,
0);
color4F
= Color4F(color3B);
color4F
= Color4F(color4B);
color4F.equals(Color4F(1,
1,
1,
1));
color4B
= Color4B(color4F);
 
color3B
= Color3B::WHITE;

继续...

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
<code>|
v2.
1

names    | v3.
0

names |
|
ccp           | Point |
|
ccpNeg        | Point::- |
|
ccpAdd        | Point::+ |
|
ccpSub        | Point::- |
|
ccpMult       | Point::* |
|
ccpMidpoint   | Point::getMidpoint |
|
ccpDot        | Point::dot |
|
ccpCrosss     | Point::cross |
|
ccpPerp       | Point::getPerp |
|
ccpRPerp      | Point::getRPerp |
|
ccpProject    | Point::project |
|
ccpRotate     | Point::rotate |
|
ccpUnrotate   | Point::unrotate |
|
ccpLengthSQ   | Point::getLengthSq() |
|
ccpDistanceSQ | Point::getDistanceSq |
|
ccpLength     | Point::getLength |
|
ccpDistance   | Point::getDistance |
|
ccpNormalize  | Point::normalize |
|
ccpForAngle   | Point::forAngle |
|
ccpToAngle    | Point::getAngle |
|
ccpClamp      | Point::getClampPoint |
|
ccpFromSize   | Point::Point |
|
ccpCompOp     | Point::compOp |
|
ccpLerp       | Point::lerp |
|
ccpFuzzyEqual | Point::fuzzyEqual |
|
ccpCompMult   | Point::Point |
|
ccpAngleSigned | Point::getAngle |
|
ccpAngle      | Point::getAngle |
|
ccpRotateByAngle | Point::rotateByAngle |
|
ccpLineInersect | Point::isLineIntersect |
|
ccpSegmentIntersect | Point::isSegmentIntersect |
|
ccpIntersectPoint | Point::getIntersectPoint |
|
CCPointMake   | Point::Point |
|
CCSizeMake    | Size::Size |
|
CCRectMake    | Rect::Rect |
|
PointZero     | Point::ZERO |
|
SizeZero      | Size::ZERO |
|
RectZero      | Rect::ZERO |
|
TiledGrid3DAction::tile | TiledGrid3DAction::getTile |
|
TiledGrid3DAction::originalTile | TiledGrid3DAction::getOriginalTile |
|
TiledGrid3D::tile | TiledGrid3D::getTile |
|
TiledGrid3D::originalTile | TiledGrid3D::getOriginalTile |
|
Grid3DAction::vertex | Grid3DAction::getVertex |
|
Grid3DAction::originalVertex | Grid3DAction::getOriginalVertex |
|
Grid3D::vertex | Grid3D::getVertex |
|
Grid3D::originalVertex | Grid3D::getOriginalVertex |
|
Configuration::sharedConfiguration | Configuration::getInstance |
|
Configuration::purgeConfiguration | Configuration::destroyInstance() |
|
Director::sharedDirector() | Director::getInstance() |
|
FileUtils::sharedFileUtils | FileUtils::getInstance |
|
FileUtils::purgeFileUtils | FileUtils::destroyInstance |
|
EGLView::sharedOpenGLView | EGLView::getInstance |
|
ShaderCache::sharedShaderCache | ShaderCache::getInstance |
|
ShaderCache::purgeSharedShaderCache | ShaderCache::destroyInstance |
|
AnimationCache::sharedAnimationCache | AnimationCache::getInstance |
|
AnimationCache::purgeSharedAnimationCache | AnimationCache::destroyInstance |
|
SpriteFrameCache::sharedSpriteFrameCache | SpriteFrameCache::getInstance |
|
SpriteFrameCache:: purgeSharedSpriteFrameCache | SpriteFrameCache::destroyInstance |
|
NotificationCenter::sharedNotificationCenter | NotificationCenter::getInstance |
|
NotificationCenter:: purgeNotificationCenter | NotificationCenter::destroyInstance |
|
Profiler::sharedProfiler | Profiler::getInstance |
|
UserDefault::sharedUserDefault | UserDefault::getInstance |
|
UserDefault::purgeSharedUserDefault | UserDefault::destroyInstance |
|
Application::sharedApplication | Application::getInstance |
|
ccc3()        | Color3B() |
|
ccc3BEqual()  | Color3B::equals() |
|
ccc4()        | Color4B() |
|
ccc4FFromccc3B() | Color4F() |
|
ccc4f()       | Color4F() |
|
ccc4FFromccc4B() | Color4F() |
|
ccc4BFromccc4F() | Color4B() |
|
ccc4FEqual()  | Color4F::equals() |
|
ccWHITE       | Color3B::WHITE |
|
ccYELLOW      | Color3B::YELLOW |
|
ccBLUE        | Color3B::BLUE |
|
ccGREEN       | Color3B::GREEN |
|
ccRED         | Color3B::RED |
|
ccMAGENTA     | Color3B::MAGENTA |
|
ccBLACK       | Color3B::BLACK |
|
ccORANGE      | Color3B::ORANGE |
|
ccGRAY        | Color3B::GRAY |
|
kBlendFuncDisable | BlendFunc::BLEND_FUNC_DISABLE |</code>


Cocos2dx 3.0 交流篇的更多相关文章

  1. Cocos2dx 3.0 过渡篇(三十一)ValueVector和Vector不得不说的故事

    本文投票地址:http://vote.blog.csdn.net/Article/Details?articleid=37834689 前天看到一个颇为纠结的选择题:有一天你遇到一个外星人,这时外星人 ...

  2. Cocos2dx 3.0 过渡篇(三十)灰机还是3D好(Sprite3D)

    如今都非常少发3.0过渡篇这一系列的博文了,原因是多方面的,一个是游戏开发进度,尽管上面并没给我什么压力,但我自己一直在赶.还有一方面是个人私生活这块.五月份确实是多事之秋,有时候真的没办法全心思去研 ...

  3. Cocos2dx 3.0 过渡篇(二十六)C++11多线程std::thread的简单使用(上)

    昨天练车时有一MM与我交替着练,聊了几句话就多了起来,我对她说:"看到前面那俩教练没?老色鬼两枚!整天调戏女学员."她说:"还好啦,这毕竟是他们的乐趣所在,你不认为教练每 ...

  4. Cocos2dx 3.0 过渡篇(二十八)C++11强类型枚举

    一朋友在微信朋友圈晒了张照片,随手点开大图,带着赞赏的眼光扫了下,恩,几个月不见.又美丽了...咦?等等,她戴的这是什么?酷炫的造型! 金属边框! 微型摄像头! 这不是传说中的谷歌眼镜么?土豪啊,还好 ...

  5. Cocos2dx 3.0 过渡篇(二十九)globalZOrder()与localZOrder()

    前天非常难得的加班到八点...为什么说难得呢?由于平时我差点儿就没加班过.六点下班后想走就走,想留就留.率直洒脱.不拘一格.尽显男儿本色.程序猿,就是这么自信! -----------这篇博客的标题本 ...

  6. Cocos2dx 3.0 过渡篇(二十五)死不了的贪食蛇(触摸版)

    上一篇写的贪食蛇的重力感应控制版,这一篇就讲下触摸控制版吧.额,也不知道写了那个贪食蛇教程究竟有没有获得沈老师的书,假设没有的话,看我不拿西瓜刀砍掉 偶尔E往事 的那啥! 重力版链接:http://b ...

  7. Cocos2dx 3.0 过渡篇(二十七)C++11多线程std::thread的简单使用(下)

    本篇接上篇继续讲:上篇传送门:http://blog.csdn.net/star530/article/details/24186783 简单的东西我都说的几乎相同了,想挖点深的差点把自己给填进去. ...

  8. cocos2d-x 3.0 rapidJson 解析操作应该注意的细节

    Size visibleSize = Director::getInstance()->getVisibleSize(); Point origin = Director::getInstanc ...

  9. cocos2dx 3.0 +VS2013 环境搭建

    1.需要javasdk,android sdk,ndk,python 2.各种环境变量配置如下: JAVA_HOME:C:\Program Files\Java\jdk1.7.0_67 Path:%J ...

随机推荐

  1. gitLab添加ssh key

    电脑新装了一台虚拟机,想要和gitLab建立一个安全的ssh连接,步骤如下 1.本机生成ssh key 系统环境:Linux 使用root用户登录,执行命令:ssh-keygen -t rsa -C ...

  2. 关于扩展IP地址空间的几个方案的探讨

    摘  要:在IP地址紧缺的背景下,IPv6.NAPT.SuIP几种解决方案应运而生.分析.比较几种方案后,可知SuIP是最佳方案. 关键词:IPv6:NAPT:SuIP:IP地址空间扩展 The In ...

  3. Codeforces Round #248 (Div. 1)——Nanami&#39;s Digital Board

    题目连接 题意: 给n*m的0/1矩阵,q次操作,每次有两种:1)将x,y位置值翻转 2)计算以(x,y)为边界的矩形的面积最大值 (1 ≤ n, m, q ≤ 1000) 分析: 考虑以(x,y)为 ...

  4. JavaScript模式读书笔记 文章3章 文字和构造

    1.对象字面量     -1.Javascript中所创建的自己定义对象在任务时候都是可变的.能够从一个空对象開始,依据须要添加函数.对象字面量模式能够使我们在创建对象的时候向其加入函数.       ...

  5. WebPack实例与前端性能优化

    [前端构建]WebPack实例与前端性能优化   计划把微信的文章也搬一份上来. 这篇主要介绍一下我在玩Webpack过程中的心得.通过实例介绍WebPack的安装,插件使用及加载策略.感受构建工具给 ...

  6. 开源Math.NET基础数学类库使用(16)C#计算矩阵秩

    原文:[原创]开源Math.NET基础数学类库使用(16)C#计算矩阵秩                本博客所有文章分类的总目录:http://www.cnblogs.com/asxinyu/p/4 ...

  7. 【原创】leetCodeOj ---Partition List 解题报告

    原题地址: https://oj.leetcode.com/problems/partition-list/ 题目内容: Given a linked list and a value x, part ...

  8. 【原创】leetCodeOj --- Interleaving String 解题报告

    题目地址: https://oj.leetcode.com/problems/interleaving-string/ 题目内容: Given s1, s2, s3, find whether s3  ...

  9. myEclipse勿删文件怎么恢复

    今天码代码的时候项目里有一个jsp文件不小心被删了,又懒得重写,然后发现myEclipse竟然可以恢复被勿删的文件,当然,也仅仅限于最近被删的文件. 具体怎么恢复呢?-------右键点击被删文件所在 ...

  10. 程序员联盟有自己的论坛啦!基于Discuz构建,还不来注册~

    我把程序员联盟网站的论坛建好了,哈哈哈.用的是Discuz这个腾讯旗下的中文bbs建设软件.正在完善论坛,添加各种模块和应用.大家可以先去注册一下:coderunity.com/bbs/forum.p ...