cocos2d-x多分辨率适配

前端之家收集整理的这篇文章主要介绍了cocos2d-x多分辨率适配前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

好好上面这张理解图片


director->getOpenGLView()->setDesignResolutionSize(960,640,ResolutionPolicy::NO_BORDER);
    //1.SHOW_ALL不变 
    //2.NO_BORDER剪裁(高度显示不完整) 
    //3.EXACT_FIT拉伸 
    //4.FIXED_HEIGHT高度不变,宽度剪裁或者留黑边 
    //5.FIXED_WIDTH宽度不变,高度度剪裁或者留黑边

    Vec2 winSize = director->getWinSize();//ABCD
    Vec2 visiableSize = director->getVisibleSize();//HIJK
    Vec2 visiableOrigin = director->getVisibleOrigin();//K点
    Rect vidiableRect = director->getOpenGLView()->getVisibleRect();//真机可视区域

    //=====在屏幕左上角放置一张图片
    auto director = Director::getInstance();
    Rect vidiableRect = director->getOpenGLView()->getVisibleRect();//真机可视区域
    ImageView* packImg = ImageView::create("Login/pack1.png");
    this->addChild(packImg);
    packImg->setAnchorPoint(Vec2(0,1));//左上角 
    packImg>setPosition(Vec2(vidiableRect.origin.x,vidiableRect.origin.y+ vidiableRect.size.height));
    //=====在屏幕左上角放置一张图片
原文链接:https://www.f2er.com/cocos2dx/340513.html

猜你在找的Cocos2d-x相关文章