Hello all,
Total noobie here but Im trying to create a simple game. I want to create a bomb object and everything is fine if I set the bomb up from within the main() loop, but if I try to make a bomb class then create a new bomb from this class, the texture no longer loads, I just get a white square instead. Can anyone help see why please?
Also can I pass a sf::IntRect() over the the class instead of having to pass over 4 individual ints? I tried changing the bomb class to get sf::IntRect textureRect and passing sf::IntRect(0,0,32,32) in the call but I just could not get it to work, so I am not sure if this is possible?
Main worry is the lack of texture anyway, like I say if I have the bomb created in main it shows the png bomb just fine, any suggestions most appreciated thanks.
Code so far:
call top create new bomb instance in main()
Bomb bomb(0,0,32,32,0,0,64,64,160,160); // would rather pass some IntRects so neaten this up!
In bomb class (bomb.h):
public:
Bomb(int texureRectX, int textureRectY, int textureRectSizeX, int textureRectSizeY, int collisionRectX, int collisionRectY, int collisionRectSizeX, int collisionRectSizeY, int posX, int posY )
{
this->setTextureRect(sf::IntRect(0,0,32,32));
this->setRelativeCollider(sf::IntRect(0,0,64,64));
this->setPosition(160, 160);
sf::Texture bombChar;
bombChar.loadFromFile("images/bomb.png");
this->setTexture(bombChar);
};