• cocos2d-x基础元素之显示对象


    bool HelloWorld::init()

    {

        if ( !Layer::init() )

        {

            return false;

        }

        

        Size visibleSize = Director::getInstance()->getVisibleSize();

        Vec2 origin = Director::getInstance()->getVisibleOrigin();

        

        //auto logo=Sprite::create("Saloon (10).png");

        

        /*auto img=Director::getInstance()->getTextureCache()->addImage("Saloon (10).png");

        

        auto logoSize=img->getContentSize();

        CCLOG("logo size:%f %f",logoSize.width,logoSize.height);

        

        auto logo=Sprite::createWithTexture(img);

        

        logo->setPosition(visibleSize/2);

        

        addChild(logo);

        */

        

        auto layer1=Layer::create();

        auto layer2=Layer::create();

        auto layer3=Layer::create();

        

        auto img1=Sprite::create("Saloon (1).png");

        auto img2=Sprite::create("Saloon (2).png");

        auto img3=Sprite::create("Saloon (11).png");

        

        img1->setAnchorPoint(Vec2(0,0));

        img2->setAnchorPoint(Vec2(0,0));

        img3->setAnchorPoint(Vec2(0,0));

        

        layer1->addChild(img1);

        layer2->addChild(img2);

        layer3->addChild(img3);

        

        addChild(layer1);

        addChild(layer2);

        addChild(layer3);

        

        layer1->setPosition(visibleSize/4);

        layer2->setPosition(visibleSize/3);

        layer3->setPosition(visibleSize/2);

        

        schedule([visibleSize,this](float f){

            

            auto scene2=Scene::create();

            auto scene2Layer=Layer::create();

            scene2->addChild(scene2Layer);

            

            auto logo=Sprite::create("Saloon (10).png");

            logo->setPosition(visibleSize/2);

            scene2Layer->addChild(logo);

            

            Director::getInstance()->replaceScene(scene2);

            

        },3,"Test");

        

        return true;

    }

  • 相关阅读:
    Python中的浅复制、深复制
    Python
    CSS中
    Fluent_Python_Part3函数即对象,05-1class-func,一等函数,函数即对象
    Python
    本地简单HTTP服务器
    Fluent_Python_Part2数据结构,04-text-byte,文本和字节序列
    Fluent_Python_Part2数据结构,03-dict-set,字典和集合
    Fluent_Python_Part2数据结构,02-array-seq,序列类型
    Codeforces 246E Blood Cousins Return(树上启发式合并)
  • 原文地址:https://www.cnblogs.com/daochong/p/5226187.html
Copyright © 2020-2023  润新知