SFML community forums
Help => Window => Topic started by: lapayo on December 01, 2011, 02:54:36 pm
-
Hello, I have a little poblem with zooming and moving the view.
Normally I would do the following:
sf::View CustomView;
App.SetView(CustomView);
CustomView.Zoom(1.5f);
But what if the current Class don´t knows the view?
Do i have to inject it?
I looked into RenderWindow and found the following:
GetView()
So I tried the following:
App->GetView().Zoom(1.5f);
But this gave me an error.
I also tried some casting:
((sf::View) App->GetView()).Zoom(1.5f);
This doesn´t produce a compiler error, but at runtime nothing happens.
Is there a way to get and change the current View?
Thanks in Advance,
Simon[/code]
-
Not in SFML 1.6, because sf::View instances had to be managed externally (so basically, SFML doesn't allow you to edit "someone else"'s view if you don't know "someone else" directly).
But in SFML 2 views are handled by copy, so you can get and set the current view from any location in the code.
-
Hey, thanks for your reply.
But how can I change it in SFML 2?
I have setup SFML 2 now, but I don´t get the view changed.
I tried the following:
((sf::View) App->GetView()).Zoom(1.5f);
//way number 2
sf::View View(App->GetView());
View.Zoom(1.5f);
App->SetView(View);
But boths methods are not working :(
EDIT: It was my fault. ;)
The second method is working. But my main-loop was resetting it always :D
Thanks for your help ;)