int Game::MouseOnDot(float x, float y, RenderWindow &renderWindow) {
Rect<int> Dot;
Event event;
Dot.left = x;
Dot.top = y;
Dot.width = 20;
Dot.height = 20;
while (renderWindow.pollEvent(event)) {
float Mx = sf::Mouse::getPosition().x;
float My = sf::Mouse::getPosition().y;
if (event.type == Event::MouseButtonReleased&&Mx > x && Mx < Dot.height && My > y && My < Dot.width){
return 1;
}
else
return 0;
}
}
도트에서 버튼을 누르면 1을 반환하고 다른 기능은 윈도우를 닫으라고 알려줍니다. 마우스 위치에 문제가 있습니까?sfml에서 마우스의 위치와 클릭 감지
while (renderWindow.isOpen()) {
processEvents(renderWindow);
float Time = clock.getElapsedTime().asSeconds();
float TimeDifference = Time - LastUpdateTime;
if (TimeDifference >= UpdateTime) {
processEvents(renderWindow);
y += 3;
if (y <= 770) {
if(Game::MouseOnDot(x, y, renderWindow)==1)
renderWindow.close();
Game::Spawn(renderWindow, Green_Dots, x, y);
LastUpdateTime = Time;
return;
여전히 MouseOnDot는 0 또는 1 그것은 창을 닫지하고 내가 왜 모르는 reutrns 때 내가 여기에 일부 붙여 작동하지 않습니다?
그리고 나는 sfml 2.0을 가지고있다. –