zoukankan      html  css  js  c++  java
  • 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;

    }

  • 相关阅读:
    Uncaught TypeError: Cannot set property 'onclick' of null
    Linuxe lftp命令(七)
    linux yum 命令(六)
    Linux vi/vim(五)
    Linux 文件与目录管理(四)
    Linux 文件基本属性(三)
    Linux 系统目录结构(二)
    Linux 系统启动过程(一)
    Java基础语法知识(笔记)——(三)泛型,String与正则
    Java基础语法知识(笔记)——(二)类与对象,接口,多态,继承,异常
  • 原文地址:https://www.cnblogs.com/daochong/p/5226187.html
Copyright © 2011-2022 走看看