Hello there,
Ok bare with me on this one, I have myself a class which is a ImageLoader which basically storing a map of sf::Texture, I also have a class which is LevelState.
Now on the construction of my LevelState it required that two references are initialized on the constructor like so
Header snippet
...
public:
LevelState(FontLoader& fontLoader, ImageLoader& imageLoader);
...
private:
ImageLoader& _imageLoader;
FontLoader& _fontLoader;
...
Class snippet
LevelState::LevelState(FontLoader& fontLoader, ImageLoader& imageLoader) : _fontLoader(fontLoader), _imageLoader(imageLoader)
{
}
now this is working fine however it only works for some of my classes, I have a method called Setup which uses my imageLoader like so
UISprite.setTexture(imageLoader.Images[ImageNames::L_UI]);
and when asking to draw that it renders perfectly. however it doesn't work for my other class.
Here is a class that works fine
LevelState::Setup
DisplayObject displayObject;
DisplayObjects.push_back(displayObject);
DisplayObjects.at(0).Setup(0, 0, imageLoader.Images[ImageNames::Background1]);
//SETUP METHOD FOR DisplayObject
void DisplayObject::Setup(int xSet, int ySet, sf::Texture& spriteSet)
{
XPos = xSet;
YPos = ySet;
Sprite.setTexture(spriteSet);
Sprite.setPosition(XPos, YPos);
}
//
My DisplayObject renders without a problem
My Enemy class however is always a white block
Enemy enemy;
Row1Enemies.push_back(enemy);
Row1Enemies[0].Setup(75, 25, _imageLoader.Images[ImageNames::L_Enemy2], EnemyType::Shooter, 0.3, 1);
//ENEMY SETUP METHOD
void Enemy::Setup(int xSet, int ySet, sf::Texture spriteSet, EnemyType type, int fireChance, int lifeSet)
{
XPos = xSet;
YPos = ySet;
Sprite.setTexture(spriteSet);
Type = type;
Status = true;
FireChance = fireChance;
Life = lifeSet;
}
//
Why on earth does my displayobject render fine and my enemy doesn't? Can anyone help me out here?