如何让它不会每次都刷新屏幕

问题描述 投票:0回答:0

如何让它在每次移动和悬停鼠标时都不会刷新屏幕,因此,屏幕会闪烁

// event handler "mouseMoved"
if (!loadlobbymousebutton && ev.type == sf::Event::mouseMoved)
{   
// checking if the mouse cursor is over the sprite
    
    if (startgamebutton.startgamebuttonspron.getGlobalBounds().contains(sf::Mouse::getPosition(win).x, sf::Mouse::getPosition(win).y))
    {   
        if (!biautifulbutton)
        {   
            cout << "Mouse over sprite!" << endl;
            startgamebutton.startgamebuttonspron.setTexture(startgamebutton.startgamebuttontexoff);
            biautifulbutton = true;
            verybiautifulbutton = true;
        }
    }
    else if (!startgamebutton.startgamebuttonspron.getGlobalBounds().contains(sf::Mouse::getPosition(win).x, sf::Mouse::getPosition(win).y))
    {   
        if (biotifulbutton)
        {   
            cout << "DICK" << endl;
            // returning the sprite to its original state
            startgamebutton.startgamebuttonspron.setTexture(startgamebutton.startgamebuttontexon);
            biautifulbutton = false;
            verybiautifulbutton = true;
        }
    }
}
if (verybiautifulbutton)
{   
    verybiautifulbutton = false;
    win.draw(startgamebutton.startgamebuttonspron);
    win.display();
}

我尝试添加标志来解决这个问题,但它没有解决我的问题,请告诉我如何解决它

c++ sfml
© www.soinside.com 2019 - 2024. All rights reserved.