The problem is this.
I have to call a particoular method of a clicked tile
if (event.type == sf::Event::MouseButtonPressed)
if(event.mouseButton.button == sf::Mouse::Left){
sf::Vector2f mouse = renderWindow.mapPixelToCoords(sf::Mouse::getPosition(renderWindow));
for (int i=0; i<tilesOnMap; i++){
sf::FloatRect bounds = tileMap.at(i).sprite.getGlobalBounds();
if (bounds.contains(mouse)){
std::cout << "clicked at x: "<< tileMap.at(i).axis << " and y : " << tileMap.at(i).ord<< std::endl; //to test the position since i still have to think about the method to create an interaction menĂ¹ with the tile
}
}
}
but since i use isometric tile (partially transparent sprites to give the isometric lines) the rects are overlying so i always get an answer from 2 tiles.
Any solution?