Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: why am I getting an error on Void...?  (Read 1343 times)

0 Members and 1 Guest are viewing this topic.

Geoffry_the_Deprogrammer

  • Newbie
  • *
  • Posts: 14
    • View Profile
    • Email
why am I getting an error on Void...?
« 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);

        }
    }

Strelok

  • Full Member
  • ***
  • Posts: 139
    • View Profile
    • GitHub
Re: why am I getting an error on Void...?
« Reply #1 on: August 27, 2014, 08:57:09 am »
First of all pass the RenderWindow(noncopyable) as reference.
« Last Edit: August 27, 2014, 08:59:04 am by Strelok »

MW2TopTenWORLD

  • Newbie
  • *
  • Posts: 23
    • View Profile
    • Email
Re: why am I getting an error on Void...?
« Reply #2 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.
« Last Edit: September 03, 2014, 02:06:54 am by MW2TopTenWORLD »

 

anything