
cocos2d-x
文章平均质量分 62
yuprxk
这个作者很懒,什么都没留下…
展开
-
cocos2d-x 中CREATE_FUNC 宏
cocos2d-2.1rc0-x-2.1.3版本中,CREATE_FUNC宏,内容如下: #define CREATE_FUNC(__TYPE__) \ static __TYPE__* create() \ { \ __TYPE__ *pRet = new __TYPE__(); \ if (pRet && pRet->init()) \ { \ p原创 2013-10-10 16:04:03 · 1267 阅读 · 0 评论 -
cocos2d-x C++的do...while(0)
在C++中,有三种类型的循环语句:for, while, 和do...while, 但是在一般应用中作循环时, 我们可能用for和while要多一些,do...while相对不受重视。 但是,最近在读我们项目的代码时,却发现了do...while的一些十分聪明的用法,不是用来做循环,而是用作其他来提高代码的健壮性。 1. do...while(0)消除goto语句。 通常,如转载 2014-04-11 11:13:26 · 514 阅读 · 0 评论 -
cocos2d-x by Example Beginner's Guide 第5章 Rocket Through
废话少说,先上游戏截图。 游戏里有几个重要的地方。 1.向量知识。 2.橡皮筋线的绘制。 3.粒子系统。 void LineContainer::draw () { switch (_lineType) { case LINE_NONE: break; case LINE_TEMP: ccDr原创 2013-12-31 23:49:54 · 1172 阅读 · 0 评论 -
我为什么把 Rocket Through游戏中的Rocket::collideWithSides()写成这样?
本文是学习cocos2d-x by Example Beginner's Guide 第5章 Rocket Through的副产物。 我们首先来看看本书的作者是怎么写Rocket::collideWithSides()的,代码如下: bool Rocket::collidedWithSides() { CCSize screenSize = CCDirector::share原创 2013-12-16 21:50:35 · 961 阅读 · 0 评论 -
cocos2d-x by Example Beginner's Guide 第5章 Rocket Through 之 粒子系统
Rocket Through cocos2d-x by Example Beginner's Guide 第5章 Rocket Through 你将学到: 1.怎么加载和设定一个粒子系统。 2.如何在CCNode中,画出图元(primitives)如,线,圆等。 3.如何使用cocos2d-x中提供的一些关于向量运算的数学方法。 什么是粒子? 粒子(或者粒子系统),是向你的游戏翻译 2013-12-05 22:19:19 · 1199 阅读 · 0 评论 -
cocos2d-x中的 实例化与内存管理
在 cocos2d-x by example beginner's guide,第2章,P23页中(翻译请凑合看) There is no Automatic Reference Counting (ARC) in cocos2d-x, so Objective-C developers who have forgotten memory management might have a pro翻译 2013-11-13 13:52:44 · 857 阅读 · 0 评论 -
cocos2d-x 中的 CCSprite
3个容器 1.CCScene 2.CCLayer 3.CCSprite 先看看作者怎么说CCSprite的 在P18:(翻译请凑合看) These contain your images and will be added to CCLayer derived containers. To my mind this is the most important class in all原创 2013-11-12 17:22:31 · 944 阅读 · 0 评论 -
Director类与Caches
在cocos2d-x example beginner's guide Ch2,P19中(翻译凑合看) The director and caches Then comes the all-knowing CCDirector and all-encompassing cache objects. CCDirector manages scenes and knows all a原创 2013-11-12 17:59:03 · 732 阅读 · 0 评论 -
需要重载 CCPoint类 的 == 吗?
在 cocos2d-2.1rc0-x-2.1.3\cocos2dx\cocoa\CCGeometry.cpp中 bool CCPoint::equals(const CCPoint& target) const { return (fabs(this->x - target.x) < FLT_EPSILON) && (fabs(this->y - target.y) <原创 2013-11-15 10:53:18 · 890 阅读 · 0 评论 -
在ccTouchesBegan 用;boundingBox 判断是不是在操作英雄
Cocos2d-x by Example Beginner's Guide,第3章 在GameLayer.ccp中 GameLayer::ccTouchBegan()中 for (int p = 0; p < 2; p++) { player = (GameSprite *) _players->objectAtIndex(p); if (player->boundingBox().c原创 2013-11-15 14:10:46 · 1449 阅读 · 0 评论 -
跟我来用cocos2d-x做一个游戏 Sky Defense
游戏截图 Sky Defense 是cocos2d-x by Example Beginner's Guide,第4章的游戏示例。 先从GameLayer::init()说起,游戏的大部分初始化,都是在这里做的。 //zeek. _screenSize = CCDirector::sharedDirector()->getWinSize(); gameCreateScree原创 2013-11-27 22:18:09 · 1719 阅读 · 0 评论