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

Author Topic: Missing Template Arguments - Sprite.SetSubRect [RESOLVED]  (Read 2322 times)

0 Members and 1 Guest are viewing this topic.

Mastax

  • Newbie
  • *
  • Posts: 2
    • View Profile
Missing Template Arguments - Sprite.SetSubRect [RESOLVED]
« on: November 28, 2011, 01:33:59 am »
I'm making a space invaders clone using MinGW CodeBlocks on Windows 7.  When compiling, I get this error:

C:\Users\Jim\Desktop\Programming\Face Invaders\invaders.h||In member function 'void invader0::spriteSetRect()':|
C:\Users\Jim\Desktop\Programming\Face Invaders\invaders.h|43|error: missing template arguments before '(' token|
C:\Users\Jim\Desktop\Programming\Face Invaders\invaders.h|44|error: missing template arguments before '(' token|
||=== Build finished: 2 errors, 0 warnings ===|

I'm guessing it has something to do with my class:

Code: [Select]
class invader0
{
    private:
        short posX, posY;  // (0-800, 0-600)
        static sf::Image Image0;
        sf::Sprite Sprite;
    public:
        static bool state0;  // (0-1)
        void setPos(short, short);
        static bool init (const std::string& ImageFile) {return Image0.LoadFromFile(ImageFile);}
        invader0() {
            Sprite.SetImage(Image0);
        }
        void spriteSetRect() {
            if (state0 == 0) {
            invader0::Sprite.SetSubRect(sf::Rect(0, 0, 16, 16));  // Error goes here
            } else {invader0::Sprite.SetSubRect(sf::Rect(16, 0, 32, 16));}
        }
};


Probably some simple mistake, but I can't think of what could be wrong.

Lo-X

  • Hero Member
  • *****
  • Posts: 618
    • View Profile
    • My personal website, with CV, portfolio and projects
Missing Template Arguments - Sprite.SetSubRect [RESOLVED]
« Reply #1 on: November 28, 2011, 01:45:58 am »
sf::Rect is templated, so you should use sf::Rect<int> or sf::Rect<float> or directly sf::IntRect (which is a typedef of sf::Rect<int>)

Mastax

  • Newbie
  • *
  • Posts: 2
    • View Profile
Missing Template Arguments - Sprite.SetSubRect [RESOLVED]
« Reply #2 on: November 28, 2011, 01:58:10 am »
Oh wow.  I was doing that on all my other classes, just not that one... Thanks for the speedy response.