cocos2d-x 实现翻牌效果

摘要: 翻牌的3D动画:CCSprite* pSprite = CCSprite::spriteWithFile("HelloWorld.png");pSprite->setPosition( ccp(size.width/2, size.height/2) ); pSprite->runAction( CCSequence::actions( CCOrbitCamera::actionWithDuration(1 , 1 , 0 , 0 , 90 , 0, 0), CCCallFuncN::actionWithTarget(this , callfuncN_selec 阅读全文
posted @ 2013-04-14 10:24 jack_yan 阅读(587) 评论(0) 推荐(0)

cocos2d-x技能冷却

摘要: 今天看了一个博客 技能冷却,内部原理 没有看懂,但在他的基础上 加了一个代理方法,使外部类能够捕获到冷却结束。博客地址http://http://blog.csdn.net/z104207/article/details/8059098 无侵权意思,效果: 首先 建了一个SkillButton的类.h文件ifndef _SKILLBUTTON_H_#define _SKILLBUTTON_H_#include "cocos2d.h"class CMTouchSpriteProtocol;class SkillButton : public cocos2d::CCNode{p 阅读全文
posted @ 2013-04-14 10:23 jack_yan 阅读(425) 评论(0) 推荐(0)

CCLabelAtlas 特效 自定义CCLabelTTF

摘要: 有时候游戏中要用到一些特殊的字体效果,特别是数字。CCLabelAtlas就可以从png图中读取文字。CCLabelAtlas* diceCount=CCLabelAtlas::labelWithString("1:", "nums_font.png", 14, 21, '0');第一个参数:显示的内容:1x,你也许会奇怪为什么是1x,因为使用的png图必须是连续的,因为程序内部是议连续的scall码识别的。9的后一位的”:“,所以先实现x就得用”:“代替。第二个参数:图片的名字第三个参数:每一个数字的宽第四个参数:每一个数字的高每五个数 阅读全文
posted @ 2013-04-14 10:22 jack_yan 阅读(245) 评论(0) 推荐(0)

cocos2d-x plist动画

摘要: CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("bearlist.plist","bearlist.png"); //从名字很容易看出,它是用来缓存图片的,内部封装了一个字典 CCSprite*flowSprite=CCSprite::create(); flowSprite->autorelease(); CCArray*frames=CCArray::create(); for (int i=0;i<<span style=" 阅读全文
posted @ 2013-04-14 10:22 jack_yan 阅读(545) 评论(0) 推荐(0)

CCSpriteBatchNode 渲染

摘要: 原文地址: http://www.cocos2dev.com/?p=331以前写过一个游戏中的天气系统,今天有人说我的天气系统有点卡,不是很好用。我看下了他的代码,发现他改了我的代码,把CCSpriteBatchNode删除了,直接用addChild,每个sprite都是重新读取的贴图。我想说,同学呀,你把暴风雪所有特效开启后,你有没有注意下你的游戏场景显示了1000多渲染批次。这能不卡吗?今天刚好有点时间,我介绍下CCSpriteBatchNode,以及利用它优化游戏渲染效率。在cocos2d-x 2.x 之后,大家都看到了左下角的FPS变成3行,多了两行数据。最上面一行是指的当前场景的渲染 阅读全文
posted @ 2013-04-14 10:21 jack_yan 阅读(207) 评论(0) 推荐(0)

cocos2d-x 时间

摘要: long long int timeSec = 1353735416;//假如这是服务器的时间 char str[64] = {0}; time_t timep = timeSec; sprintf(str, "%s",asctime(gmtime(&timep)));打印出 Sat Nov 24 05:36:56 2012相当与 OC中的 NSData需要转成 NSData 格式的时间 tm* timeStuct = gmtime(&timep); sprintf(str, "d/d/d d:d", timeStuct->tm_y 阅读全文
posted @ 2013-04-14 10:21 jack_yan 阅读(198) 评论(0) 推荐(0)

CCSpriteBatchNode cocos2d-x使用

摘要: 1、先说下渲染批次:这是游戏引擎中一个比较重要的优化指标,指的是一次渲染凋用。也就是说,渲染的次数越少,游戏的运行效率越高。2、CCSpriteBatchNode就是cocos2d-x为了降低渲染批次而建立的一个专门管理精灵的类。 CCSpriteBatchNode* batchNode = CCSpriteBatchNode::create("Icon.png", 1000); batchNode->setPosition(CCPointZero); this->addChild(batchNode); for(int i = 0;i < 1000;++ 阅读全文
posted @ 2013-04-14 10:19 jack_yan 阅读(330) 评论(0) 推荐(0)

CCSprite学习

摘要: CCSprite 的加载CCSprite*spret=CCSprite::spriteWithFile("Icon.png");spret->setPosition( ccp(size.width/2, size.height/2) );this->addChild(spret);CCSprite*spret=CCSprite::spriteWithFile("Icon.png",CCRectMake(0, 0, 20 ,10 ));//加载图片的一个区域spret->setScale(3);//设置CCSprite的缩放比例spret 阅读全文
posted @ 2013-04-14 10:16 jack_yan 阅读(179) 评论(0) 推荐(0)

射击小游戏一03(碰撞检测)

摘要: /* 申明数组的时候一定要注意retain:比如 _targets = CCArray::create(); _targets->retain();*/ voidHelloWorld::update(CCTime dt){ CCArray *projectilesToDelete = CCArray::create(); projectilesToDelete->retain(); for (int i = 0; i < _projectiles->count(); i++) { CCSprite *projectile = (CCSprite... 阅读全文
posted @ 2013-04-14 10:00 jack_yan 阅读(442) 评论(0) 推荐(0)

射击小游戏一01(子弹添加添加)

摘要: void HelloWorld::ccTouchesEnded(CCSet *touches,cocos2d::CCEvent *event){ CCTouch *touch = (CCTouch*)(touches->anyObject()); CCPoint location = touch->getLocationInView(); location = CCDirector::sharedDirector()->convertToGL(location); CCSize winSize = CCDirector::sharedDirector()->ge... 阅读全文
posted @ 2013-04-13 11:29 jack_yan 阅读(421) 评论(0) 推荐(0)