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

Author Topic: How do I use a rectangleshape as a class member?  (Read 1017 times)

0 Members and 1 Guest are viewing this topic.

C0dedSurvivor

  • Newbie
  • *
  • Posts: 10
    • View Profile
How do I use a rectangleshape as a class member?
« 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.

SpeCter

  • Full Member
  • ***
  • Posts: 151
    • View Profile
Re: How do I use a rectangleshape as a class member?
« Reply #1 on: November 12, 2015, 03:24:23 pm »
You forgot to put the namespace before RectangleShape it is sf::RectangleShape.

C0dedSurvivor

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: How do I use a rectangleshape as a class member?
« Reply #2 on: November 12, 2015, 03:27:40 pm »
Thanks, I forgot to migrate my namespace call... That fixed it.