Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Help with mouse clicks?  (Read 1403 times)

0 Members and 1 Guest are viewing this topic.

cowchin12

  • Newbie
  • *
  • Posts: 9
    • View Profile
    • Email
Help with mouse clicks?
« on: January 12, 2013, 11:52:33 pm »
So I want to have a window that has three buttons that can be pressed, using the mouse, and depending on which button is pressed, the window changes. I have no idea how to do this,  could someone please help? Here is an example:

#include "stdafx.h"
#include <SFML/Graphics.hpp>
#include <iostream>
#include <SFML/Audio.hpp>
#include <SFML/System.hpp>
#include <SFML/Window.hpp>

sf::Texture mainMenu;
mainMenu.loadFromFile("menu1.jpg");
sf::Sprite menu1(mainMenu);                 //This loads an image with three buttons to be pressed
sf::RenderWindow window(sf::VideoMode(800,600,64),"Help me D:");
sf::Event event1;
window.clear();
window.draw(menu1);
window.display();

int _tmain(int argc, _TCHAR* argv[])
{
      while(window.isOpen())
      {
      while(window.pollEvent(event1))
      {
         if (event1.type == sf::Event::Closed)
         {
            window.close();
         }
                        if(//mouse is pressed at a certain spot) //THIS IS WHERE IM CONFUSED
                        {
                                  // Do some stuff................
                        }
               }
     }
}

Thanks for any help
« Last Edit: January 12, 2013, 11:55:32 pm by cowchin12 »

cire

  • Full Member
  • ***
  • Posts: 138
    • View Profile
Re: Help with mouse clicks?
« Reply #1 on: January 13, 2013, 12:12:37 am »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10801
    • View Profile
    • development blog
    • Email
Re: Help with mouse clicks?
« Reply #2 on: January 13, 2013, 12:17:29 am »
And for further reference, SFML has one of the best maintained documentations.

Also please make sure to use the code=cpp tag, when posting code.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything