Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Player View dont stop with the Player  (Read 692 times)

0 Members and 1 Guest are viewing this topic.

Jan666

  • Jr. Member
  • **
  • Posts: 64
    • View Profile
Player View dont stop with the Player
« 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??

Jan666

  • Jr. Member
  • **
  • Posts: 64
    • View Profile
Re: Player View dont stop with the Player
« Reply #1 on: May 23, 2022, 12:54:52 pm »
Ok i got a solution