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

Pages: [1]
1
Window / Re: getLocalBounds() with text objects?
« on: May 02, 2019, 04:39:04 pm »
mapPixelToCoords worked even though im not using a view. I don't know why it works but it does. Thanks!

if(equationsButtonText.getGlobalBounds().contains(window.mapPixelToCoords({event.mouseButton.x, event.mouseButton.y})

2
Window / Re: getLocalBounds() with text objects?
« on: May 01, 2019, 01:08:26 am »
Forgot to send myself the .cpp file from school but no I'm not using a view. So ill check that tomorrow
And when I used getGlobalBounds I believe it gave me a FloatRect error and when i tried
cout << equationsButtonText.getLocalBounds(); to see what it was puting in for the coords it gave me a FloatRect error.

3
Window / Re: getLocalBounds() with text objects?
« on: April 30, 2019, 05:41:23 pm »
while(window.isOpen()){
        Event event;

            while(window.pollEvent(event)){

                switch(event.type)
                {

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

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

                    default:
                    break;
                    }
                }
            }

Okay yeah I just fixed the KeyPressed before I checked the post, it gets to here:
> cout << "  if(event.mouseButton.button == Mouse::Left){" << endl; (Testing to see how far it goes)
and im assuming the if statement just isnt valid at that point

4
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]