简体   繁体   English

缩放窗口时如何在应用程序中修复背景

[英]How to fix the background in the app when scaling the window, sfml

Help with sfml, it is necessary to make so that the background application when scaling is not changed, 有关sfml的帮助,有必要使后台应用程序在缩放时不发生变化,

int main()
{
    ....
    View view;
    view.reset(FloatRect(0, 0, 1200, 700));
    float zoom = 1.0f;

    while (window.isOpen())
    {   
        ProcessEvents(window, clickState, zoom, view);
        ...
        window.setView(view);
        window.draw(bg);
        window.draw(vecBody.at(0).sprite);
        window.draw(text);  
    }
}

Without zoom 没有变焦 在此处输入图片说明

With zoom 带变焦 在此处输入图片说明

When you scale the view in or out, you need to adapt the background sprite to scale out or in (ie the inverse operation you applied on the view). 当您放大或缩小视图时,需要调整背景精灵以进行放大或缩小(即您对视图应用的逆操作)。

Have a look at sf::Sprite::setScale . 看看sf :: Sprite :: setScale

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM