摘要: 原文地址:http://www.cocos2dev.com/?p=331以前写过一个游戏中的天气系统,今天有人说我的天气系统有点卡,不是很好用。我看下了他的代码,发现他改了我的代码,把CCSpriteBatchNode删除了,直接用addChild,每个sprite都是重新读取的贴图。我想说,同学呀,你把暴风雪所有特效开启后,你有没有注意下你的游戏场景显示了1000多渲染批次。这能不卡吗?今天刚好有点时间,我介绍下CCSpriteBatchNode,以及利用它优化游戏渲染效率。在cocos2d-x 2.x 之后,大家都看到了左下角的FPS变成3行,多了两行数据。最上面一行是指的当前场景的渲染批 阅读全文
posted @ 2013-04-25 23:00 Jzong 阅读(157) 评论(0) 推荐(0) 编辑
摘要: virtual void setTexture (CCTexture2D *texture)//设置精灵的纹理virtual CCTexture2D * getTexture (void)//获取精灵的纹理bool initWithTexture (CCTexture2D *pTexture)//根据纹理初始化精灵bool initWithTexture (CCTexture2D *pTexture, const CCRect &rect)//根据纹理指定的区域初始化精灵bool initWithSpriteFrame (CCSpriteFrame *pSpriteFrame)//根据 阅读全文
posted @ 2013-04-23 22:44 Jzong 阅读(183) 评论(0) 推荐(0) 编辑
摘要: Introductioncocos2d supports both TTF (True Type Fonts) labels, and texture atlas labels.Pros and Cons of TTF labels: ( CCLabelTTF )All the pros of TTF fonts: any size, kerning support, etc.Easy to use. No need to use an external editor.The creation/update is very slow since a new texture will be cr 阅读全文
posted @ 2013-04-22 15:12 Jzong 阅读(285) 评论(0) 推荐(0) 编辑
摘要: Menu vs. MenuItemsCCMenu is just a collection of CCmenuItems, and those menu items are what define the various buttons or labels you will have as part of your menu. Since the CCmenu contains all of the menu items, it controls the alignment and position of those items. By default,all of the menu item 阅读全文
posted @ 2013-04-22 15:06 Jzong 阅读(129) 评论(0) 推荐(0) 编辑
摘要: 1void SaveScreenshot() 2{ 3 CCSize size = CCDirector::sharedDirector()->getWinSize(); 4 CCRenderTexture* texture = CCRenderTexture::create((int)size.width, (int)size.height); 5 texture->setPosition(ccp(size.width/2, size.height/2)); 6 texture->begin(); 7 CCDirector::sharedDir... 阅读全文
posted @ 2013-04-22 14:37 Jzong 阅读(136) 评论(0) 推荐(0) 编辑
摘要: IntroductionCCString is inherited from the CCObject class. CCObject exist primarily as an automatic memory management object. CCString provided a series of interface such as create, convert etc..Useful MethodsCreation : 1 2 /** create a string with std string, you can also pass a c string pointer... 阅读全文
posted @ 2013-04-22 14:30 Jzong 阅读(321) 评论(0) 推荐(0) 编辑
摘要: IntroductionCCArray is a fully supported class of cocos2d. It is used for optimization in your game. You can find the CCArray class files in the cocos2d/Support group in the project. It’s used internally by cocos2d and is similar to Apple’s NSMutableArray class—except that CCArray performs better.No 阅读全文
posted @ 2013-04-22 14:08 Jzong 阅读(482) 评论(0) 推荐(0) 编辑
摘要: CCDirector类对应cocos2d-x引擎里的导演,整个游戏里只有一个导演,游戏开始和结束时都需要调用CCDirector的方法完成游戏初始化或者销毁的工作。cocos2d-x引擎里面除了提供CCDirector,还提供了一个CCDisplayLinkDirector,CCDisplayLinkDirector是一个可以自动刷新的CCDirector.CCScene * getRunningScene (void) //获取当前运行的场景double getAnimationInterval (void)//获取当前的FPSvirtual void setAnimationInterva 阅读全文
posted @ 2013-04-21 21:56 Jzong 阅读(286) 评论(0) 推荐(0) 编辑
摘要: 2013 - 04 - 21 阅读全文
posted @ 2013-04-21 21:48 Jzong 阅读(111) 评论(0) 推荐(0) 编辑