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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Bushider

Pages: [1]
1
Graphics / Re: Checking if mouse is on the texture.
« 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. :)

2
Graphics / 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

3
Graphics / Re: Checking if the mouse is on a sprite
« on: April 04, 2015, 09:45:41 pm »
I have almost the same question. I'm just learing SFML, and copying a code from youtube tutorial. I've did everything exactly the same as the tutorial creator, and his code was compiled my wasn't.

It's like that :

Quote
ivoid 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;
   }
}


Where button is array of text. Error occures in place where i check if mouse position is on texture. lines :
Quote
if (button[0].getGlobalBounds().contains(sf::Mouse::getPosition(updatetarget).x, sf::Mouse::getPosition(updatetarget).y)

!button[0].getGlobalBounds().contains(sf::Mouse::getPosition(updatetarget).x, sf::Mouse::getPosition(updatetarget).y)

Type of error :

Quote
syntax error : '::'
'(' : illegal token on right side of '::'

Could anyone help me ? I'm new to programing. :)
Thanks a lot!

Pages: [1]