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

Author Topic: SF::View or SF::RenderWindow?  (Read 386 times)

0 Members and 2 Guests are viewing this topic.

Niety

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
SF::View or SF::RenderWindow?
« on: February 26, 2025, 01:50:05 am »
Hi!

I'm developing a simple "map creator" tool, in which the end goal is to have multiple "menus" with "image icon" and then drag to the main window to "paint the map".

I'm having some problems in trying to identify the collision between the mouse::left button and "image icon" (sf::rectangleShape), because the collision use the mouse vs rectangle location based on the current window, but I need to do it based on the sf::View. How to proceed?

Another thing: for having "menus" in the window, I should open more sf::renderWindows and try to "attach" them to the main one?

G.

  • Hero Member
  • *****
  • Posts: 1598
    • View Profile
Re: SF::View or SF::RenderWindow?
« Reply #1 on: February 26, 2025, 03:30:15 am »
Use mapPixelToCoords and mapCoordsToPixel to convert mouse coordinates to view coordinates, and vice versa.

I think people usually dislike when softwares use multiple windows for their different menus (but your mileage may vary...). You can use several views, one for your "main content" that probably moves or scales, and one (or more) for your user interface that is fixed.

Hapax

  • Hero Member
  • *****
  • Posts: 3410
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: SF::View or SF::RenderWindow?
« Reply #2 on: February 26, 2025, 05:24:06 pm »
You can also use "viewports" to separate a window into multiple areas but note that this can be confusing at first, especially if you're not very comfortable with views already.

Try this view tutorial if you'd like to understand a bit more about how they work:
https://github.com/SFML/SFML/wiki/Tutorial%3A-Using-View
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

 

anything