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

Author Topic: Overlapping views to create GUI and world view.  (Read 3093 times)

0 Members and 1 Guest are viewing this topic.

AntonBesp

  • Newbie
  • *
  • Posts: 2
    • View Profile
Overlapping views to create GUI and world view.
« on: December 18, 2019, 08:04:35 pm »
I want to make user be able to zoom in/out the world. Like in games such as Terraria where you need to press + to zoom in and - to zoom out. I know that this feature is implemented in one method of View class. But also I have GUI that mustn't be resized on zooming. Can I create two views(one for GUI, another for world) and overlap them to achieve it? Will GUI view be transparent in places where it is wanted to be transparent?

G.

  • Hero Member
  • *****
  • Posts: 1572
    • View Profile
Re: Overlapping views to create GUI and world view.
« Reply #1 on: December 18, 2019, 08:06:40 pm »
Yes, definitely.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6283
  • Thor Developer
    • View Profile
    • Bromeon
Re: Overlapping views to create GUI and world view.
« Reply #2 on: December 18, 2019, 08:49:40 pm »
Yes, this is absolutely no problem.
Transparency is achieved with the alpha channel -- it's not affected by the view, only the color of the underlying pixel in the window.

A render cycle would be quite simple:
clear();

setView(world);
draw(world);

setView(gui);
draw(gui);

display();
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

 

anything