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

Author Topic: Is there a way of scaling the screen?  (Read 2049 times)

0 Members and 1 Guest are viewing this topic.

Murii

  • Newbie
  • *
  • Posts: 10
    • View Profile
    • Email
Is there a way of scaling the screen?
« on: January 12, 2014, 11:01:03 am »
Hello guys i have some sprites that are 16x16 and 32x32 but they are too small,so i thought i can scale the screen so i can see better the sprites but i cant find the function for scaling,can you help me?Thanks !

Xornand

  • Jr. Member
  • **
  • Posts: 78
  • C++ / Python
    • View Profile
Re: Is there a way of scaling the screen?
« Reply #1 on: January 12, 2014, 11:21:35 am »
You can use the zoom() method of the current window's View. For example:
yourRenderWindow.getView().zoom(0.5); // Magnifies everything two times.

Alternatively, you can call scale() method on individual sprites if you want to magnify only specific elements on the screen.

Murii

  • Newbie
  • *
  • Posts: 10
    • View Profile
    • Email
Re: Is there a way of scaling the screen?
« Reply #2 on: January 12, 2014, 11:51:21 am »
Thx!!

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Is there a way of scaling the screen?
« Reply #3 on: January 12, 2014, 02:38:00 pm »
Hello guys i have some sprites that are 16x16 and 32x32 but they are too small
Maybe you should make them bigger? Scaling them with SFML will make everything pixelated, I'm not sure if that's what you want.

yourRenderWindow.getView().zoom(0.5); // Magnifies everything two times.
This won't work directly because of encapsulation. You have to get the view, modify it, and set it again.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Xornand

  • Jr. Member
  • **
  • Posts: 78
  • C++ / Python
    • View Profile
Re: Is there a way of scaling the screen?
« Reply #4 on: January 12, 2014, 03:17:17 pm »
yourRenderWindow.getView().zoom(0.5); // Magnifies everything two times.
This won't work directly because of encapsulation. You have to get the view, modify it, and set it again.
True. I didn't notice that the return value from getView() is constant. Use this instead:
auto view = yourRenderWindow.getView();
view.zoom(0.5);
yourRenderWindow.setView(view);