SFML community forums

Help => Graphics => Topic started by: C0dedSurvivor on November 12, 2015, 03:00:00 pm

Title: How do I use a rectangleshape as a class member?
Post by: C0dedSurvivor on November 12, 2015, 03:00:00 pm
I am trying to create collision detection for rectangleshapes, and I decided to try and attach it directly to the shape by calling the rectangleshape constructor as a member of the bounding box class, and it is giving me all kinds of errors. I can't figure out how to fix it, or if I am even able to do this.
Here's my code:

#include <SFML/Graphics.hpp>

const int OBoxA = 20;
const int IBoxA = 20;

class box{
public:
   RectangleShape drawBox;
   int xOffset;
   int xLength;
   int xOrigin;
   int yOffset;
   int yLength;
   int yOrigin;

   box(){
      xLength = -1;
   }
        //I set the values through a different method besides calling it
};

My error message is:
Error   18   error C2146: syntax error : missing ';' before identifier 'drawBox'
Error   19   error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

If you need more, please let me know. Thanks.
Title: Re: How do I use a rectangleshape as a class member?
Post by: SpeCter on November 12, 2015, 03:24:23 pm
You forgot to put the namespace before RectangleShape it is sf::RectangleShape.
Title: Re: How do I use a rectangleshape as a class member?
Post by: C0dedSurvivor on November 12, 2015, 03:27:40 pm
Thanks, I forgot to migrate my namespace call... That fixed it.