SFML community forums

General => General discussions => Topic started by: AntonBesp on December 18, 2019, 08:04:35 pm

Title: Overlapping views to create GUI and world view.
Post by: AntonBesp 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?
Title: Re: Overlapping views to create GUI and world view.
Post by: G. on December 18, 2019, 08:06:40 pm
Yes, definitely.
Title: Re: Overlapping views to create GUI and world view.
Post by: Nexus 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();