Menu

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.

Show posts Menu

Messages - Nabeel Nazir

#26
Help requests / Re:
11 September 2013, 18:01:38
i have placed cat.wav file now at both addresses!! Still its not working !
C:\Users\corleone\Documents\Visual Studio 2010\Projects\MySfml\MySfml\Debug
C:\Users\corleone\Documents\Visual Studio 2010\Projects\MySfml\MySfml\Release

#27
Help requests / Re:
11 September 2013, 17:53:34
 :(  :(
#28
 why this code not playing voice of cat i.e. when selected CAT from ListBox and press speak button (its not working now agaain)!
I PLACE MY CAT.WAV FILE AT THIS PATH 
C:\Users\corleone\Documents\Visual Studio 2010\Projects\MySfml\MySfml


#include <SFML/Audio.hpp>
#include <TGUI/TGUI.hpp>
#include <conio.h>

//void function(const tgui::Callback& callback)
//{
//    if (callback.id == 1)
// {
// //std::cout << "Hello world" << std::endl;
// }
//
//
//
//}

int main()
{
sf::SoundBuffer buffer;
sf::Sound sound;
sound.setBuffer(buffer);

    // Create the window
    sf::RenderWindow window(sf::VideoMode(800, 600), "Window");
    tgui::Gui gui(window);

    // Load the font (you should check the return value to make sure that it is loaded)
    gui.setGlobalFont("C:/Users/corleone/Documents/Visual Studio 2010/Projects/MySfml/MySfml/TGUI-0.6-alpha2-Visual-C++10-2010-32-bits/TGUI-0.6-alpha2/fonts/DejaVuSans.ttf");



    tgui::Button::Ptr button(gui);
    button->load("C:/Users/corleone/Documents/Visual Studio 2010/Projects/MySfml/MySfml/TGUI-0.6-alpha2-Visual-C++10-2010-32-bits/TGUI-0.6-alpha2/widgets/Black.conf");
button->setPosition(250, 350);
    button->setText("SPEAK");
    button->setSize(300, 40);
//button->setCallbackId(1);
//button->bindCallbackEx(function, tgui::Button::LeftMouseClicked);

tgui::ListBox::Ptr listBox(gui);
listBox->load("C:/Users/corleone/Documents/Visual Studio 2010/Projects/MySfml/MySfml/TGUI-0.6-alpha2-Visual-C++10-2010-32-bits/TGUI-0.6-alpha2/widgets/Black.conf");
listBox->setSize(150, 120);
    listBox->setItemHeight(30);
    listBox->setPosition(300, 100);
    listBox->addItem("HORSE");
    listBox->addItem("CAT");
    listBox->addItem("DONKEY");
listBox->addItem("LION");
listBox->addItem("GOAT");
listBox->setCallbackId(2);
//listBox->getSelectedItem();
//listBox->bindCallbackEx(function, tgui::ListBox::ItemSelected);

tgui ::Callback callback;

button->bindCallback(tgui::Button::LeftMouseClicked);
button->setCallbackId(1);


    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
if(event.key.code==sf::Keyboard::P)
sound.play();
            // Pass the event to all the widgets (if there would be widgets)
            gui.handleEvent(event);
        }

        window.clear();

        // Draw all created widgets
        gui.draw();

        window.display();
}

while (gui.pollCallback(callback))
{


/* listBox->bindCallback(tgui::ListBox::ItemSelected);
listBox->setCallbackId(2);*/

if(callback.id==1)
{
if (listBox->getSelectedItem()=="CAT")
{
if (!buffer.loadFromFile("cat.wav"))
{
std::cout << "Error while loading music" << std::endl;
}
else
{
sound.play();
}

}
}

}



return EXIT_SUCCESS;
}






#29
why this code not playing voice of cat i.e. when selected CAT from ListBox and press speak button ?


#include <SFML/Audio.hpp>
#include <TGUI/TGUI.hpp>
#include <conio.h>

//void function(const tgui::Callback& callback)
//{
//    if (callback.id == 1)
// {
// //std::cout << "Hello world" << std::endl;
// }
//
//
//
//}

int main()
{
    // Create the window
    sf::RenderWindow window(sf::VideoMode(800, 600), "Window");
    tgui::Gui gui(window);

    // Load the font (you should check the return value to make sure that it is loaded)
    gui.setGlobalFont("C:/Users/corleone/Documents/Visual Studio 2010/Projects/MySfml/MySfml/TGUI-0.6-alpha2-Visual-C++10-2010-32-bits/TGUI-0.6-alpha2/fonts/DejaVuSans.ttf");



    tgui::Button::Ptr button(gui);
    button->load("C:/Users/corleone/Documents/Visual Studio 2010/Projects/MySfml/MySfml/TGUI-0.6-alpha2-Visual-C++10-2010-32-bits/TGUI-0.6-alpha2/widgets/Black.conf");
button->setPosition(250, 350);
    button->setText("SPEAK");
    button->setSize(300, 40);
//button->setCallbackId(1);
//button->bindCallbackEx(function, tgui::Button::LeftMouseClicked);

tgui::ListBox::Ptr listBox(gui);
listBox->load("C:/Users/corleone/Documents/Visual Studio 2010/Projects/MySfml/MySfml/TGUI-0.6-alpha2-Visual-C++10-2010-32-bits/TGUI-0.6-alpha2/widgets/Black.conf");
listBox->setSize(150, 120);
    listBox->setItemHeight(30);
    listBox->setPosition(300, 100);
    listBox->addItem("HORSE");
    listBox->addItem("CAT");
    listBox->addItem("DONKEY");
listBox->addItem("LION");
listBox->addItem("GOAT");
listBox->setCallbackId(2);
//listBox->getSelectedItem();
//listBox->bindCallbackEx(function, tgui::ListBox::ItemSelected);

tgui ::Callback callback;

button->bindCallback(tgui::Button::LeftMouseClicked);
button->setCallbackId(1);
while (gui.pollCallback(callback))
{


/* listBox->bindCallback(tgui::ListBox::ItemSelected);
listBox->setCallbackId(2);*/

sf::SoundBuffer buffer;
if(callback.id==1)
{
if (listBox->getSelectedItem()=="CAT")
{
if (!buffer.loadFromFile("cat.wav"))
{
std::cout << "Error while loading music" << std::endl;
}
else
{
sf::Sound sound;
sound.setBuffer(buffer);
sound.play();
}

}
}

}



    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();

            // Pass the event to all the widgets (if there would be widgets)
            gui.handleEvent(event);
        }

        window.clear();

        // Draw all created widgets
        gui.draw();

        window.display();
}
return EXIT_SUCCESS;
}





#30
Help requests / Re:
09 September 2013, 07:25:35
thanks ! :)
#31
Help requests / Re:
08 September 2013, 21:30:07
I have made the button and list box .. now its time to move on to the next step !
is there any way to add a ".wav" sound file in this code ? so that when a particular animal is selected and speak button is pressed then the selected animal's voice will be played ? i need help !
#32
thanks a lot ... now its working ! :))) !
that's why i remove other reply's !
yeah this is a small project given by my university professor...
this project is simple but complex and i am sure you guys will help me in completing this task :))
the project is about to create a list box which contains different animal names .. and a button.. when a particular name of animal  is selected .. and button is pressed then voice of that animal should be played ! 
#33
this is the error on console !
#34
Help requests / Re:
08 September 2013, 19:03:52
Please also tell me how can i make list Box in this code ???
and secondly why font file is not loading in this code ???? I need help  ! :(
#35


#include <SFML/window.hpp>
#include <SFML/system.hpp>
#include <SFML/audio.hpp>
#include <SFML/graphics.hpp>
#include <TGUI/TGUI.hpp>
//#include <SFML/Video.hpp>
//#include <conio.h>

//#include <iostream>

int main()
{
    // Create the window
    sf::RenderWindow window(sf::VideoMode(800, 600), "Window");
    tgui::Gui gui(window);

    // Load the font (you should check the return value to make sure that it is loaded)
    gui.setGlobalFont("C:/Users/corleone/Documents/Visual Studio 2010/Projects/MySfml/MySfml/TGUI-0.6-alpha2-Visual-C++10-2010-32-bits/TGUI-0.6-alpha2/fonts/DejaVuSans.ttf");

    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();

            // Pass the event to all the widgets (if there would be widgets)
            gui.handleEvent(event);
        }

        //window.clear();

        // Draw all created widgets
        gui.draw();

tgui::Button::Ptr button(gui);
button->load("C:/Users/corleone/Documents/Visual Studio 2010/Projects/MySfml/MySfml/TGUI-0.6-alpha2-Visual-C++10-2010-32-bits/TGUI-0.6-alpha2/widgets/Button/BabyBlue/Normal.conf");

        window.display();
   








}
return EXIT_SUCCESS;
}



:(


#36
Help requests / Re: why this code is not working ?
08 September 2013, 18:43:44


#include <SFML/window.hpp>
#include <SFML/system.hpp>
#include <SFML/audio.hpp>
#include <SFML/graphics.hpp>
#include <TGUI/TGUI.hpp>
//#include <SFML/Video.hpp>
//#include <conio.h>

//#include <iostream>

int main()
{
    // Create the window
    sf::RenderWindow window(sf::VideoMode(800, 600), "Window");
    tgui::Gui gui(window);

    // Load the font (you should check the return value to make sure that it is loaded)
    gui.setGlobalFont("C:/Users/corleone/Documents/Visual Studio 2010/Projects/MySfml/MySfml/TGUI-0.6-alpha2-Visual-C++10-2010-32-bits/TGUI-0.6-alpha2/fonts/DejaVuSans.ttf");

    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();

            // Pass the event to all the widgets (if there would be widgets)
            gui.handleEvent(event);
        }

        //window.clear();

        // Draw all created widgets
        gui.draw();

tgui::Button::Ptr button(gui);
button->load("C:/Users/corleone/Documents/Visual Studio 2010/Projects/MySfml/MySfml/TGUI-0.6-alpha2-Visual-C++10-2010-32-bits/TGUI-0.6-alpha2/widgets/Button/BabyBlue/Normal.conf");

        window.display();
   








}
return EXIT_SUCCESS;
}



:(


#37
i found this from your tutorials !  ... https://tgui.weebly.com/v05---button.html
#38
Help requests / I want to add a button to my window.
08 September 2013, 15:54:26
I am using this code from your tutorials , but its not working , it is saying that there is no addbutton() function
tgui::Button* button = window.addButton();
button->load("TGUI/objects/Button/Black");
button->setText("example button");
button->setSize(200, 50);
button->setPosition(100, 50);


, please help me ! :(