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

Author Topic: Problems with Sprite derived class  (Read 2380 times)

0 Members and 1 Guest are viewing this topic.

KevinZ

  • Newbie
  • *
  • Posts: 5
    • View Profile
Problems with Sprite derived class
« on: December 30, 2010, 04:23:26 am »
I have created a class derived from Sprite, but when I try to draw an object from this class a white rectangle is drawn instead of the image.

This for example, when I use this class it renders a white rectangle, but when I directly use sf::Sprite it shows the image fine.
Code: [Select]
#include <SFML/Graphics.hpp>

class SDerived : public sf::Sprite
{
public:
    SDerived(sf::Image SDImg) : sf::Sprite(SDImg){}
};


Could someone tell me why this doesn't work?

Thanks.

Grimshaw

  • Hero Member
  • *****
  • Posts: 631
  • Nephilim SDK
    • View Profile
Problems with Sprite derived class
« Reply #1 on: December 30, 2010, 04:40:03 am »
Hello, try passing the sf::Image by reference:

SDerived(sf::Image &img) : sf::Sprite(img)

KevinZ

  • Newbie
  • *
  • Posts: 5
    • View Profile
Problems with Sprite derived class
« Reply #2 on: December 30, 2010, 04:51:59 am »
Thanks! That did the trick.

 

anything