SFML community forums
Help => Window => Topic started by: cowchin12 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
-
http://www.sfml-dev.org/tutorials/2.0/window-events.php
Hello, tutorial.
-
And for further reference, SFML has one of the best maintained documentations (http://www.sfml-dev.org/documentation/2.0/annotated.php).
Also please make sure to use the code=cpp tag, when posting code.