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

Author Topic: Checking if mouse is on the texture.  (Read 1465 times)

0 Members and 1 Guest are viewing this topic.

Bushider

  • Newbie
  • *
  • Posts: 3
    • View Profile
Checking if mouse is on the texture.
« on: April 05, 2015, 12:49:53 am »
Hello, one of Forum users told me to creat this topic.
So as i said befor the problem is with code :
void MainMenu::Update(FrameWork &frame, sf::RenderWindow &updatetarget, float frametime)
{
        if (button[0].getGlobalBounds().contains(sf::Mouse::getPosition(updatetarget).x, sf::Mouse::getPosition(updatetarget).y) &&
                (button[0].getColor() != sf::Color::Red))
        {
                button[0].setColor(sf::Color::Blue);
                playselect = true;
        }
        else if (!button[0].getGlobalBounds().contains(sf::Mouse::getPosition(updatetarget).x, sf::Mouse::getPosition(updatetarget).y)
                && (button[0].getColor() == sf::Color::White))
        {
                button[0].setColor(sf::Color::White);
                playselect = false;
        }
}

The if ( statement was closed, it wasn't the reason, i've misscopied that. Sorry for my mistake.
I can read error i'm just begining with SFML.
Error in MainMenu.cpp is
I've checked the type that contains method returns, and it's boolean, so if i the mouse is on the texture displayed on the window, it should return true and check the color of the texture - correct me if my logic is wrong. :)

see reference to function template instantiation 'bool sf::Rect<float>::contains(T,T) const' being compiled
1>          with
1>          [
1>              T=float
1>          ]

but on the error list i can see also this one :
syntax error : '::'
'(' : illegal token on right side of '::'
Those two redirect me to SFML library - Rect.inl

Also i'll land a screenshot of my VS.
http://i61.tinypic.com/idt2e8.png

Bushider

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Checking if mouse is on the texture.
« Reply #1 on: April 05, 2015, 04:26:47 pm »
Please if someone could close this topic. I've found answere here :
http://en.sfml-dev.org/forums/index.php?topic=10216.0

Binary1248 has answered. Thanks a lot. :)

 

anything