SFML community forums

Help => General => Topic started by: Geoffry_the_Deprogrammer on August 27, 2014, 08:36:19 am

Title: why am I getting an error on Void...?
Post by: Geoffry_the_Deprogrammer on August 27, 2014, 08:36:19 am
it says "expected class, delegate, enum, interface, or struct" It was working before, I could have accidentally deleted something, but its Unlikely... I have no idea what this means... here is my code...


        public void Draw(RenderWindow window, float delta)
        {
            window.Draw(background);
            window.Draw(player);
            window.Draw(enemy);
            window.Draw(dead);

        }
    }
Title: Re: why am I getting an error on Void...?
Post by: Strelok on August 27, 2014, 08:57:09 am
First of all pass the RenderWindow(noncopyable) as reference.
Title: Re: why am I getting an error on Void...?
Post by: MW2TopTenWORLD on August 28, 2014, 02:13:45 pm
First...
I can see other bracket after the void brackets, did you putted it into a class?


Also do not name the void with public... if it is inside a class just do this

class awesomeClass
{
public:
 //public voids go here

private:
 //private voids go here
}
 

And now a problem with the void itself...

You wrote

 public void Draw(RenderWindow window, float delta)
        {
            window.Draw(background);
            window.Draw(player);
            window.Draw(enemy);
            window.Draw(dead);

        }
 

YOU need to do
 ... Draw(RenderWindow *window, ...)
        {
           window->Draw(background);
           ...

        }
 

Notice the * and ->.

And when you are calling the funtion you cannot do Draw(window,....); You need to do Draw(&window,.....); ...

I used a pointer (*) maybe you can use a reference... but pointers work for me.

Hope I helped.