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

Author Topic: View wont move.  (Read 5023 times)

0 Members and 1 Guest are viewing this topic.

ostkaka

  • Newbie
  • *
  • Posts: 5
    • View Profile
View wont move.
« on: July 10, 2013, 11:44:47 pm »
My class Camera : public sf::View stopped to work properly after I updated to sfml 2.0. It worked with sfml 1.6. In the constructor I can change its size, rotate and move it. But then it wont do anything of that in its methods  :-\.

This is the method I use:
Code: [Select]
void Camera::Update(App& app)
{
if (currentEntity != nullptr)
{
float deltaX = currentEntity->getX()+8-getCenter().x;
float deltaY = currentEntity->getY()+8-getCenter().y;
float speedFactor = atan(app.getFrameTime()*speed)*2/3.14159265358979323846264338327950288419;

std::cout << speedFactor << " ;( ;( ;( :(\n";

setCenter(getCenter().x + deltaX*speedFactor, getCenter().y + deltaY*speedFactor);
}
}

What's wrong?  :'(
« Last Edit: July 10, 2013, 11:48:00 pm by ostkaka »

hipsterdufus

  • Newbie
  • *
  • Posts: 28
    • View Profile
    • Email
Re: View wont move.
« Reply #1 on: July 10, 2013, 11:50:29 pm »
I was actually working on the same problem with my code, planned to get back at it tonight. I'll let you know if I figure anything out. I've never had a working view before though, this is my first shot at it. It just seemed like setCenter wasn't doing anything for me.

mateandmetal

  • Full Member
  • ***
  • Posts: 171
  • The bird is the word
    • View Profile
    • my blog
Re: View wont move.
« Reply #2 on: July 11, 2013, 12:38:40 am »
Why dont you use aggregation instead of inheritance?

Inside your class:
private:
    sf::View m_view;
 
- Mate (beverage) addict
- Heavy metal addict _lml
- SFML 2 addict
- My first (and free) game: BichingISH!

ostkaka

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: View wont move.
« Reply #3 on: July 11, 2013, 12:49:14 am »
It's easier with camera.getCenter().  :-\

hipsterdufus

  • Newbie
  • *
  • Posts: 28
    • View Profile
    • Email
Re: View wont move.
« Reply #4 on: July 11, 2013, 07:51:14 am »
I figured out that you have to call setView on your window (EACH TIME YOU CHANGE THE VIEW LOCATION) after calling setCenter on the view. After reading the documentation I was under the impression you just had to set the view to your window and any subsequent changes to it would automatically be binded to the window. In any case, this is what you have to do each frame:

m_View.setCenter(<vector location>)
mWindow.setView(m_View)

Let me know if that works for you.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: View wont move.
« Reply #5 on: July 11, 2013, 09:03:05 am »
Wow, it seems that the more I emphasize an important point, the less people see it.

From the tutorial, in a big red box:

Quote
When you call setView, the render-target keeps a copy of the view, not a pointer to the original one. So whenever you update your view, you need to call setView again to apply the modifications.

This is really disappointing, I've spent one year to rewrite the complete set of tutorials, trying to put every important point in them.

 >:( >:( >:( >:( >:( >:(
« Last Edit: July 11, 2013, 09:04:47 am by Laurent »
Laurent Gomila - SFML developer

binary1248

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1405
  • I am awesome.
    • View Profile
    • The server that really shouldn't be running
Re: View wont move.
« Reply #6 on: July 11, 2013, 09:32:02 am »
Wow, it seems that the more I emphasize an important point, the less people see it.

From the tutorial, in a big red box:

Quote
When you call setView, the render-target keeps a copy of the view, not a pointer to the original one. So whenever you update your view, you need to call setView again to apply the modifications.

This is really disappointing, I've spent one year to rewrite the complete set of tutorials, trying to put every important point in them.

 >:( >:( >:( >:( >:( >:(
You try too hard to document SFML well ;D. You should adopt the SFGUI documentation philosophy, minimal doxygen and tell people to go read code if they want more information ;).

On a serious note, you shouldn't be surprised if people "overlook" such things or don't read the documentation properly or at all. Since you intend on making SFML so easy to use, even for beginners, people get the impression that their auto-complete is all they need to get something done, even when switching from 1.6 to 2.0 ::). You need to add booby traps to the interface to force people to read every single word of the documentation/tutorials and lock threads that are created because they failed to do so. We all know it's in everyone's best interest if people learn to do a bit of (proper) troubleshooting on their own ;). A side effect of this is a lot of hate that will circulate, but everybody knows that negative emotions drive humans to do things more than positive ones :P.
SFGUI # SFNUL # GLS # Wyrm <- Why do I waste my time on such a useless project? Because I am awesome (first meaning).

hipsterdufus

  • Newbie
  • *
  • Posts: 28
    • View Profile
    • Email
Re: View wont move.
« Reply #7 on: July 11, 2013, 09:36:12 am »
Heh, sorry. I was just looking at the API documentation for sf::View, not the tutorial. Guess I should look there more often.

In any case, SFML is the easiest library I've ever used. The tutorials and documentation are super easy to read.

ostkaka

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: View wont move.
« Reply #8 on: July 11, 2013, 01:02:36 pm »
I read the tutorial, but I missed that somehow.  :o

 

anything