SFML community forums

Help => Graphics => Topic started by: Jan666 on May 23, 2022, 11:50:10 am

Title: Player View dont stop with the Player
Post by: Jan666 on May 23, 2022, 11:50:10 am
Hi
I have another question about sf::View. It is center to my Player and follow him. But if the Player collide with a wall and stop the view still moves if the move button is pressed. So here is my code when the Player  collide:
...

void player::plrBounce(Vector2f &wallBounce){
       
wallBounce = plrSprite.getPosition();
        plrSprite.setPosition(wallBounce.x, wallBounce.y +5);
       
}

...

if(plr.plrSprite.getGlobalBounds().intersects(WallRect.getGlobalBounds())){
       
                plr.plrBounce(wallBounce);

 

and here is my view setting:

View plrview( FloatRect(0, 0, 1300, 2600));
    plrview.setCenter(plr.plrSprite.getPosition());

 

So what could i do that the playerview is parenting to the player and stops when he stops??
Title: Re: Player View dont stop with the Player
Post by: Jan666 on May 23, 2022, 12:54:52 pm
Ok i got a solution