SFML community forums
Help => Window => Topic started by: Eragon0605 on June 14, 2010, 01:00:16 am
-
Alright, so I'm making a tic-tac-toe game. I want to make it so that if the user clicks the upper left-hand corner of the screen, a 'X' appears. I am trying to use the following code:
while (App.GetEvent(Event))
{
unsigned int MouseX = Input.GetMouseX(); // Error 1
unsigned int MouseY = Input.GetMouseY(); // Error 2
bool LeftButtonDown = Input.IsMouseButtonDown(sf::Mouse::Left); //Error 3
if ((LeftButtonDown == true) && (MouseX << 50) && (MouseY << 50))
{
SprCross1.SetPosition(25.f, 25.f);
X1 = 1;
}
}
When I try to compile I get three errors saying "error: expected primary-expression before '.' token". What is the problem? I am following the tutorial's example exactly. Oh, and yes, I did put "using sf::Input" at the beginning of the program. I am using GCC, Linux Ubuntu, and C++.
-
You'll need to put this outside of the loop somewhere:
const sf::Input& Input = App.GetInput();
-
Ah, thanks! The compiler error is gone! Doesn't do what I want, but there's probably just some other messed-up piece of code somewhere...
EDIT: Found and corrected error. Was totally unrelated. Thanks kitchen for fixing yet another error. (It was still very much in the early development stage)
-
Ah, thanks! The compiler error is gone! Doesn't do what I want, but there's probably just some other messed-up piece of code somewhere...
The error is right here:
(MouseX << 50) && (MouseY << 50)
You think you are doing a less-than comparison when you are in fact doing a left shift by 50 bits on MouseX and MouseY. Change it to this:
(MouseX < 50) && (MouseY < 50)