cocos2d学习笔记
Posted 微风&细雨
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了cocos2d学习笔记相关的知识,希望对你有一定的参考价值。
//粒子系统,使用系统自己的粒子系统的书写方法 if(!CCLayer::init()) return false; CCTexture2D* fire=CCTextureCache::sharedTextureCache()->addImage("fire.png"); CCParticleSystem* firePartical = CCParticleFire::create(); firePartical->setTexture(fire); this->addChild(firePartical); firePartical->setPosition(ccp(100,100)); //自定义粒子系统的使用方法,需要plist文件,plist通过对应的编辑器获取 if(!CCLayer::init()) return false; ParticleSystemQuad* system = ParticleSystemQuad::create("BoilingFoam.plist"); system->setTextureWithRect(Director::getInstance()->getTextureCache()->addImage("fire.png"), Rect(0, 0, 64, 64)); this->addChild(system); system->setPosition(300,300); system->retain(); //精灵使用方法,下面为设置100个精灵随机加载到420*420的位置 for (int i = 0; i < 100; i++) { CCSprite* pSprite = CCSprite::create("tp_4.png"); CC_BREAK_IF(!pSprite); pSprite->setPosition(ccp(CCRANDOM_0_1()*420,CCRANDOM_0_1()*420)); this->addChild(pSprite); } //精灵纹理集使用方法 CCSpriteBatchNode* ccSprite = CCSpriteBatchNode::create("tp_4.png"); if (!ccSprite) return false; this->addChild(ccSprite); for (int i = 0; i < 100; i++) { CCSprite* ccsprite2 = CCSprite::createWithTexture(ccSprite->getTexture()); ccsprite2->setPosition(ccp(CCRANDOM_0_1() * 600, CCRANDOM_0_1() * 600)); ccSprite->addChild(ccsprite2); } //显示helloworld // // Size visibleSize = Director::getInstance()->getVisibleSize(); // Vec2 origin = Director::getInstance()->getVisibleOrigin(); // // ///////////////////////////// // // 2. add a menu item with "X" image, which is clicked to quit the program // // you may modify it. // // add a "close" icon to exit the progress. it‘s an autorelease object // auto closeItem = MenuItemImage::create( // "CloseNormal.png", // "CloseSelected.png", // CC_CALLBACK_1(HelloWorld::menuCloseCallback, this)); // //closeItem->setPosition(Vec2(origin.x + visibleSize.width - closeItem->getContentSize().width/2 , // origin.y + closeItem->getContentSize().height/2)); // // create menu, it‘s an autorelease object // auto menu = Menu::create(closeItem, NULL); // menu->setPosition(Vec2::ZERO); // this->addChild(menu, 1); // ///////////////////////////// // // 3. add your codes below... // // add a label shows "Hello World" // // create and initialize a label // auto label = Label::createWithTTF("my app ", "fonts/Marker Felt.ttf", 24); // // // position the label on the center of the screen // label->setPosition(Vec2(origin.x + visibleSize.width/2, // origin.y + visibleSize.height - label->getContentSize().height)); // // add the label as a child to this layer // this->addChild(label, 1); // // add "HelloWorld" splash screen" // auto sprite = Sprite::create("HelloWorld.png"); // // position the sprite on the center of the screen // sprite->setPosition(Vec2(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y)); // // add the sprite as a child to this layer // this->addChild(sprite, 0); // // return true;
以上是关于cocos2d学习笔记的主要内容,如果未能解决你的问题,请参考以下文章
《Cocos2d-x游戏开发实战精解》学习笔记1--在Cocos2d中显示图像
[原创]java WEB学习笔记61:Struts2学习之路--通用标签 property,uri,param,set,push,if-else,itertor,sort,date,a标签等(代码片段