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

Pages: [1]
1
Graphics / Re: Obtaining a sf::Sprite value thanks to a pointer
« on: April 08, 2012, 02:30:16 pm »
Ok, I finally managed to solve it :D
Thank you so much, what an honor to be help by a SFML developer  :'(

2
Graphics / Re: Obtaining a sf::Sprite value thanks to a pointer
« on: April 05, 2012, 11:20:15 pm »
You're a genius!! Thank you so much, I'm struggling with it since yesterday!
But my addSprite() function only accepts Personnage type class. It means that I can't register any object unless it is a Personnage class.

void addSprite(Personnage *joueur);

You talked about inheriting from an Entity class with a draw() function. What did you mean? I don't see how I could use a parent class to accept any type of object. I confess I have some gaps in C++, which can be quite penalizing...

3
Graphics / Re: Obtaining a sf::Sprite value thanks to a pointer
« on: April 05, 2012, 09:40:38 pm »
I think I understood what you mean. Consequently, I tried to directly create a Personnage entity when I use the function addSprite() :

drawing1.addSprite(new Personnage);

The only problem is that I can't make understand to Drawing::drawFrame() function that sf::Sprite has a function called GetSprite().

void Drawing::drawFrame()
{
    for(i=0; i<drawTable.size(); i++)
    {
        m_app->Draw(*drawTable[i].getSprite());
    }
    i = 0;
}

Tell me if you don't understand what I did. For my part, I do have a headache just looking at this piece of code  :(

4
Graphics / Re: Obtaining a sf::Sprite value thanks to a pointer
« on: April 04, 2012, 10:41:50 pm »
Oh, yeah, I see what you mean. I confess I'm powerless now, how could I manage to keep a "permanent" value returned by GetSprite() ? I do think you're right, it would entirely explain my error message.

5
Graphics / Re: Obtaining a sf::Sprite value thanks to a pointer
« on: April 04, 2012, 10:17:22 pm »
eXpl0it3r : that's it, m_app is actually a pointer on the sf::RenderWindow. In fact, I created a "Drawing" class that draws all the elements of the scene. To that extent, I had to create a pointer on app to be able to Draw the Sprites easily.
Here is the implementation code :

class Drawing
{
    public:
        Drawing(sf::RenderWindow *app);
        void addSprite(sf::Sprite *sprite); //Ajouter un sprite en liste
        void drawFrame(); //Placer tous les sprites contenus

    private:
        std::vector<sf::Sprite*> drawTable;
        int i;
        sf::RenderWindow *m_app;
        int ordreY;
};

Laurent : Sure, I use it in main(), each time I have to add a sprite in the scene :

int main()
{
    RenderWindow app(VideoMode(800, 600, 32), "RPG Test");

    Drawing drawing1(&app); //Moteur graphique
    Personnage joueurP;
    drawing1.addSprite(& joueurP.GetSprite());
...
}

6
Graphics / Obtaining a sf::Sprite value thanks to a pointer
« on: April 04, 2012, 09:37:28 pm »
Hi everyone.
For some reason that would be long to explain, I've got an array filled with pointers, all pointing on a Sprite address. Now I have to Draw() theses Sprites thank to a loop. Everything seems alright, but when I run the code, here is the horrible message delivered by the programme :



Here is the part of the code dealing with it :

std::vector<sf::Sprite*> drawTable; //The array containing pointers
 

//The function that allows to add Sprites addresses in the array
void Drawing::addSprite(Sprite *sprite)
{
    drawTable.push_back(sprite);
}

//The function that allows to display all the sprites
void Drawing::drawFrame()
{
    for(i=0; i<drawTable.size(); i++)
    {
        m_app->Draw(*drawTable[i]); //Here is the line causing the crash !
    }
    i = 0;
}

The doc informs me that the Draw() function prototype is that one :
virtual void sf::RenderTarget::Draw(const Drawable & Object) [virtual]

I confess I'm a bit lost. I don't feel at ease with this concept of virtual function or else... Some one may give me some help?
Thanks for reading me, and have a good day !

Pages: [1]