zoukankan      html  css  js  c++  java
  • 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;
  • 相关阅读:
    SharePoint 2013 通过HttpModule 管理视图权限
    SharePoint 2013 内容部署报错
    SharePoint 2013 日历视图兼容性问题
    SharePoint 2013 JavaScript 对象判断用户权限
    SharePoint 2013 PowerShell命令备份还原报错
    SharePoint 2013 修改表单认证登录页面
    SharePoint 2013 表单认证使用ASP.Net配置工具添加用户
    linux下永久添加静态路由
    CAN协议,系统结构和帧结构
    STM32串口的设置和库函数的介绍
  • 原文地址:https://www.cnblogs.com/weifengxiyu/p/5820149.html
Copyright © 2011-2022 走看看