cocos2d-x 分享某类的静态实例方法与调用

摘要: 获取当前某类的静态实例方法:如下代码,举例类名为: PlayScene在 .h 文件中声明:class PlayScene : public CCLayer{public: //获取当前PlayScene的静态实例(分享) static PlayScene* sharedPlay(); static CCScene* createPlayScene(); virtual bool init(); CREATE_FUNC(PlayScene);};在 .cpp 文件中定义:#include "PlayScene.h"static PlayScene* ps;Pla... 阅读全文
posted @ 2013-04-25 15:12 jack_yan 阅读(524) 评论(0) 推荐(1)

cocos2d-x 多触点监听

摘要: /首先到cocos2d-x项目下的ios文件夹下,找到AppController.mm文件,在函数 didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 中添加如下函数: [__glView setMultipleTouchEnabled:YES]; bool HelloWorld::init() { if ( !CCLayer::init() ) { return false; } //开启多触点监听务必调用此函数 setTo... 阅读全文
posted @ 2013-04-25 15:11 jack_yan 阅读(237) 评论(0) 推荐(0)

cocos2d-x CCAnimation实现动画

摘要: CCSprite* sp = CCSprite::create("crop1.png"); sp->setPosition(ccp(170, 200)); addChild(sp); CCAnimation* animation = CCAnimation::create(); animation->addSpriteFrameWithFileName("crop1.png"); animation->addSpriteFrameWithFileName("crop2.png"); animation->add 阅读全文
posted @ 2013-04-25 15:10 jack_yan 阅读(336) 评论(0) 推荐(0)

cocos2d-x 矩形碰撞检测

摘要: bool HelloWorld::init() { ////////////////////////////// // 1. super init first if ( !CCLayer::init() ) { return false; } CCSprite* sp1 = CCSprite::create("Icon.png"); sp1->setPosition(ccp(200, 160)); addChild(sp1, 0, 1); CCSprite*... 阅读全文
posted @ 2013-04-25 15:09 jack_yan 阅读(360) 评论(0) 推荐(0)

cocos2d-x 切换场景动画

摘要: //扇形 逆时针 // CCTransitionScene* transition = CCTransitionProgressRadialCCW::create(1.5f, MyScene::createMyScene()); // CCDirector::sharedDirector()->replaceScene(transition); //扇形 顺时针 // CCTransitionScene* transiton = CCTransitionProgressRadialCW::create(1.2f, MyScene::createM... 阅读全文
posted @ 2013-04-25 15:08 jack_yan 阅读(271) 评论(0) 推荐(0)

cocos2d-x 22种特效

摘要: CCSprite* sp = CCSprite::create("Default.png"); sp->setPosition(ccp(240, 160)); addChild(sp); //常见的22种特效 //3D晃动的特效 // CCActionInterval* shaky3D = CCShaky3D::create(5, CCSize(10, 10), 15, false); // sp->runAction(shaky3D); //3D瓷砖晃动特效 // CCActionInter... 阅读全文
posted @ 2013-04-25 15:07 jack_yan 阅读(444) 评论(0) 推荐(0)

cocos2d-x 粒子移动类型

摘要: //清晰移动类型的作用 CCParticleSystem* particleSystem1 = CCParticleSun::create(); particleSystem1->setTexture(CCTextureCache::sharedTextureCache()->addImage("fire.png")); //自动释放 particleSystem1->setAutoRemoveOnFinish(true); //设置移动类型:自由模式 particleSystem1->setPositionType(kCCPositi... 阅读全文
posted @ 2013-04-25 15:06 jack_yan 阅读(327) 评论(0) 推荐(0)

cocos2d-x游戏摇杆的实现方法

摘要: 虚拟摇杆类起名为:HRocker 下面是 HRocker.h 文件:[cpp] view plaincopy#include <iostream> #include "cocos2d.h" using namespace cocos2d; //枚举型:用于标识摇杆与摇杆的背景 typedef enum{ tag_rocker, tag_rockerBG, }tagForHRocker; class HRocker : public CCLayer { public: //创建摇杆,摇杆图片,摇杆背景图片,起始坐标 ... 阅读全文
posted @ 2013-04-25 15:05 jack_yan 阅读(529) 评论(0) 推荐(0)

cocos2d-x 自带11种粒子特效

摘要: /粒子特效 //爆炸效果 CCParticleSystem* particleSystem = CCParticleExplosion::create(); particleSystem->setTexture(CCTextureCache::sharedTextureCache()->addImage("stars.png")); addChild(particleSystem); //火焰效果 CCParticleSystem* particleSystem = CCParticleFire::create... 阅读全文
posted @ 2013-04-25 15:04 jack_yan 阅读(490) 评论(0) 推荐(0)

TexturePacker的使用(图片打包再一起)

摘要: CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("last.plist","last.png"); CCTexture2D *texture=CCTextureCache::sharedTextureCache()->textureForKey("last.png"); CCSpriteBatchNode *node=CCSpriteBatchNode::createWithTexture(texture); addChild(no 阅读全文
posted @ 2013-04-24 09:40 jack_yan 阅读(535) 评论(0) 推荐(0)