SFML community forums

Help => Graphics => Topic started by: shev on June 16, 2016, 10:01:27 pm

Title: manipulating non saved object
Post by: shev 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!
Title: AW: detecting if clicked on any object
Post by: eXpl0it3r 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.