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.


Topics - KokosNaPalmie

Pages: [1]
1
Window / Mouse wheel scroll detection still not working
« on: March 14, 2020, 08:20:58 pm »
I'm trying to make settings state for my game and my mouse scroll detection is not working. I tried to find solution on sfml website, youtube and forums, even this one, but the only answer I got was
"Flush your cout buffer if you want it to print something. << std::endl or << std::flush", and the post is now far away from interest
Here's the function I made to move a view:
void Options::CheckEvents()
{
    if (sf::Keyboard::isKeyPressed(sf::Keyboard::Escape))   // quit check
        this->quit = true;

    while(window->pollEvent(this->evnt))
    {
        if (this->evnt.type == sf::Event::MouseWheelScrolled)
        {
            std::cout << "[DEBUG]: mouse wheel scrolled\n"; // this one prints, but not always
                                                            // (for example 4 prints per 10s of scrolling)

            if (evnt.mouseWheelScroll.delta < 0 && view->getCenter().y > WinHeight / 2) // if view center is not too far away
            {
                std::cout << "[DEBUG]: View moved up\n"; // not printing, even when I remove this ^ check
                view->move(sf::Vector2f(0, -view_speed * this->dt));
            }
            if (evnt.mouseWheelScroll.delta > 0 && view->getCenter().y < WinHeight * 2) // if view center is not too far away
            {
                std::cout << "[DEBUG]: View moved down\n"; // not printing, even when I remove this ^ check
                view->move(sf::Vector2f(0,  view_speed * this->dt));
            }
        }
    }
}

And for good news, this code works in main class

2
System / Mouse wheel scroll detection not working
« on: March 13, 2020, 04:04:06 pm »
I'm trying to make settings state for my game and my mouse scroll detection is not working. I tried to find solution on sfml website, youtube and forums but my code still doesn't want to work
Here's the function I made to move a view:
void Options::CheckEvents()
{
    if (sf::Keyboard::isKeyPressed(sf::Keyboard::Escape))   // quit check
        this->quit = true;

    while(window->pollEvent(this->evnt))
    {
        if (this->evnt.type == sf::Event::MouseWheelScrolled)
        {
            std::cout << "[DEBUG]: mouse wheel scrolled\n"; // this one prints, but not always
                                                            // (for example 4 prints per 10s of scrolling)

            if (evnt.mouseWheelScroll.delta < 0 && view->getCenter().y > WinHeight / 2) // if view center is not too far away
            {
                std::cout << "[DEBUG]: View moved up\n"; // not printing, even when I remove this ^ check
                view->move(sf::Vector2f(0, -view_speed * this->dt));
            }
            if (evnt.mouseWheelScroll.delta > 0 && view->getCenter().y < WinHeight * 2) // if view center is not too far away
            {
                std::cout << "[DEBUG]: View moved down\n"; // not printing, even when I remove this ^ check
                view->move(sf::Vector2f(0,  view_speed * this->dt));
            }
        }
    }
}

Additionally when I move the code out of pollEvent function the view moves only when I move my mouse

3
Window / Mouse Position not working
« on: March 08, 2020, 09:13:07 pm »
I'm working on a game and have a problem with mouse position relative to screen, window and view
void Things::UpdateMousePos() // parent class to objects like buttons, texts etc.
{
    this->mPosScreen = sf::Mouse::getPosition(); // working on fullscreen
    this->mPosWindow = sf::Mouse::getPosition(); // not working
    this->mPosView = this->window->mapPixelToCoords(sf::Mouse::getPosition(*this->window)); // crashing the game
}

I've searched quite a lot, but even the view tutorial on sfml site hasn't resolved it

Pages: [1]