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

Pages: [1]
1
Audio / Re: SFML/Audio: Music::Music() undefined reference?
« on: January 27, 2014, 05:35:17 pm »
No I didn't :). Thank you!

I hadn't a thought of that until you said it. I can finally use the SFML/Audio class! :)

2
Audio / SFML/Audio: Music::Music() undefined reference?
« on: January 27, 2014, 04:43:22 pm »
Hi! I've tried to use the SFML/Audio class. But when I create an object for example:

Code: [Select]
    sf::Music mus;
    mus.openFromFile("music.wav");
    mus.play();

And try to use it. It gives me undefined reference. Even to the constructor?!
Well, this is the full code if it is anything wrong with it:

Code: [Select]
#include <iostream>
#include "SFML/Window.hpp"
#include "SFML/Graphics.hpp"
#include "SFML/Audio.hpp"

using namespace std;

int main()
{
    sf::RenderWindow window(sf::VideoMode(640, 480), "Window");
    sf::Event event;
    sf::Music mus;
    mus.openFromFile("music.wav");
    mus.play();
    while (window.isOpen())
    {
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
            {
                window.close();
            }
        }
        window.clear(sf::Color::Black);
        window.display();
    }
    return 0;
}

Isn't it enough with just including these lines?:
Code: [Select]
#include "SFML/Window.hpp"
#include "SFML/Graphics.hpp"
#include "SFML/Audio.hpp"

Or do I have to include even more directiories?
The bunch of errors I'm getting is undefined reference
to everything. This is how it looks like:

EDITED:
Couldn't get an image of it to the forum :(

3
Thanks! That's useful information but I had to use a sf::RenderWindow& pWindow instead of a sf::RenderTarget& pWindow

Because the sf::RenderTarget didn't provide a display() function. So I needed to use a sf::RenderWindow& pWindow instead. But thanks for your help! :)

4
Hi! I've tried to create a function that can draw a SFML sprite directly onto the screen. The problem is that when I where going to use this function I didn't know that you couldn't pass a sf::RenderWindow to the pWindow parameter in that function. The compiler just generated a bunch of errors :(.

This is how the function looks like and how I've thought it could work. 

// Draw's the texture onto the screen
void TextureManger::DrawTexture(string id, sf::RenderWindow pWindow)
{
    pWindow.clear(sf::Color::Black);
    pWindow.draw(this->getSprite[id]);
    pWindow.display();
}

But here is how I thought if using it which maybe were a bad idea :(

The window is of course a sf::RenderWindow.
DrawTexture("image", window);

First before I realized that I were using a sf::RenderWindow. I used a sf::Window. But when
I where going to create the function the sf::Window had no .clear(<COLOR>), .display() functions.
So I were forced to use a sf::RenderWindow instead.

Is it anyone who can help me out with this problem? Or have a solution to a function that can solve this problem? Thanks for help if so! :)

5
General / Re: SFML: texture.loadFromFile("image.png"); Fails!
« on: January 06, 2014, 10:16:19 pm »
[SOLVED] I were missing that I'm only loaded the image. But I didn't DRAW it to the screen using a sprite.

Code: [Select]
        sf::Sprite sprite;
        sprite.setTexture(texture);
        window.draw(sprite);

6
General / SFML: texture.loadFromFile("image.png"); Fails!
« on: January 06, 2014, 09:35:26 pm »
Hi all! I have problem with loading this image onto the screen so I can see it. Here is my code if it is anything wrong with it:


Yes, I have the image in the directory and I know it is in a .png format. The CMD Window doesn't give me any error. But the window won't show the image. I'm using CodeBlocks and when I read the tutorial it said:

but when you launch your program from your IDE (Visual Studio, Code::Blocks, ...) the working directory is sometimes set to the project directory instead. This can generally be changed easily in the project settings.

And if that is the problem where do I find "project settings" in CodeBlocks? I didn't found it when I clicked on the project tab

Code: [Select]
#include <iostream>
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>

using namespace std;

int main()
{
    sf::RenderWindow window(sf::VideoMode(640, 480), "Window");
    sf::Event event;
    while (window.isOpen())
    {
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
            {
                window.close();
            }
        }
        window.clear(sf::Color::Black);

        sf::Texture texture;
        if (!texture.loadFromFile("image.png"))
        {
            cout << "Could not load image.png" << endl;
        }

        window.display();
    }

    return 0;
}

7
General / Re: Mouse Input: X, Y Values of the Mouse
« on: January 06, 2014, 10:09:39 am »
Or maybe just keep on reading the tutorials to get the mouse like that. I didn't think before I wrote :)

8
General / Mouse Input: X, Y Values of the Mouse
« on: January 06, 2014, 09:54:23 am »
Hi! I'm wondering if I have for example a SFML window with a image of a start button or something. How can I do so that when I click that button it happens something. I just want to know how to do if I want to click in a special area within the window. In if the mouse wheren't in the special area it shouldn't happen anything. Here is my code to make it clearer what I want to achieve.

Code: [Select]
#include <iostream>
#include <SFML/Window.hpp>

using namespace std;

int main()
{
    sf::Window window;
    window.create(sf::VideoMode(640, 480), "Window");
    sf::Event event;

    window.setKeyRepeatEnabled(false);
    while (window.isOpen())
    {
        while (window.pollEvent(event))
        {
            switch (event.type)
            {
                case sf::Event::Closed: window.close(); break;
                case sf::Event::MouseMoved:
                    cout << "X: " << event.mouseMove.x << endl;
                    cout << "Y: " << event.mouseMove.y << endl;
                    break;
                default: break;
            }
                if (event.type == sf::Event::MouseMoved)
                {
                    cout << "Mouse Moved";
                    if (event.type == sf::Event::MouseButtonPressed)
                    {
                        cout << "Mouse Button Pressed";
                    }
                }
        }
    }

    return 0;
}

9
General / Re: SFML Beginner: Which is the first tutorial I should read?
« on: January 05, 2014, 08:19:55 pm »
Not from top to bottom the tutorials are totally mixed. But I'm think the first thing that is important to know is how to create a SFML window :)

10
General / SFML Beginner: Which is the first tutorial I should read?
« on: January 05, 2014, 08:12:33 pm »
Hi SFML users! I'm wondering if I want to learn to use SFML what is the first tutorial I should read at the SFML official website (http://sfml-dev.org/tutorials)?

I don't really know where to start. Thanks for replies!

Pages: [1]
anything