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

Author Topic: manipulating non saved object  (Read 1305 times)

0 Members and 1 Guest are viewing this topic.

shev

  • Newbie
  • *
  • Posts: 1
    • View Profile
manipulating non saved object
« on: June 16, 2016, 10:01:27 pm »
hi everyone,

I'm coding a game which has a matrix of tiles and text on each tile. I display them according to a non graphics vector-meaning I display the string in each object and so I don't actually have the board in my graphics class.
The problem is that I now want to implement a drag and drop function to swap texts between the tiles. I can know if  the user pressed on an area on which a text stands yet how can I then manipulate that text?
in other words- can I ask the mouse if he's on any object and then access the object?
or must I now save all the texts in the graphics as well?

Thank you so much!
« Last Edit: June 16, 2016, 10:22:59 pm by shev »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11027
    • View Profile
    • development blog
    • Email
AW: detecting if clicked on any object
« Reply #1 on: June 16, 2016, 10:15:19 pm »
I'm not exactly sure that I understand your setup, but you'll have to make the mapping between tiles and texts yourself. Whether you save the positions extra or recalculate them based on the text's positions is up to you.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/