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 - Kelekom

Pages: [1]
1
Window / getLocalBounds() with text objects?
« on: April 30, 2019, 04:46:58 pm »
while(window.isOpen()){
        Event event;

            while(window.pollEvent(event)){
            window.clear(Color(210, 180, 140));
            window.draw(titleText);
            window.draw(equationsButtonText);
            window.draw(variablesButtonText);
            window.draw(onlineResourcesButtonText);
            window.draw(unitsButtonText);
            window.display();
                switch(event.type)
                {

                    case Event::Closed:
                        window.close();
                        break;

                    case Event::KeyPressed:
                        if(event.type == Event::MouseButtonPressed){
                            if(event.mouseButton.button == Mouse::Left){
                                if(equationsButtonText.getLocalBounds().contains(event.mouseButton.x, event.mouseButton.y)){
                                    cout << "This works!" << endl;
                                }
                            }
                        }

                    default:
                    break;

                    }
                }
            }

Not sure what part of this is wrong but clicking on the text doesn't work and im not entirely sure why. I'm thinking getLocalBounds doesn't work for text objects but really don't want to draw invisible sprites over each button unless theres a faster way to do that.

Pages: [1]
anything