博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
cocos2d学习笔记
阅读量:4612 次
发布时间:2019-06-09

本文共 3240 字,大约阅读时间需要 10 分钟。

//粒子系统,使用系统自己的粒子系统的书写方法    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;

 

转载于:https://www.cnblogs.com/weifengxiyu/p/5820149.html

你可能感兴趣的文章
[zz]GDB调试精粹及使用实例
查看>>
数据库的创建和删除
查看>>
最简单的三层实例【插入据
查看>>
设计模式学习笔记——Prototype原型模式
查看>>
pom.xml里有红叉报错的解决办法
查看>>
Perl last和next的用法区别
查看>>
Selenium 管理 Cookies
查看>>
exceptionfunction[LeetCode]Permutations
查看>>
Linux(2)_常用命令2
查看>>
自定义分页
查看>>
[转]DELPHI——调试(1)
查看>>
JS秒数转成分秒时间格式
查看>>
xp_cmdshell 命令的开启与关闭,和状态查询
查看>>
Linux sudoers
查看>>
MySQL详解(18)-----------分页方法总结
查看>>
bzoj 4595 激光发生器
查看>>
multi cookie & read bug
查看>>
js时间转换
查看>>
(转载) Android Studio你不知道的调试技巧
查看>>
队列实现霍夫曼树
查看>>