I've heard of the white box issue, but why is only a black box rendering where my sprite is? My code was working fine until I gave the sprite its own class, then it stopped responding to all setPositions()'s and is only showing a 10*10 black box (the texture is 10*10 as well). Here is the new code I tried to implement
Flashlight::Flashlight(){
light.setOrigin(light.getGlobalBounds().width / 4, light.getGlobalBounds().height / 2);
light.setPosition(250, 250);
light.setTexture(imgr.GetImage("images/light.png"));
}
light light is a class sprite. I set their velocites like this:
if(sf::Keyboard::isKeyPressed(sf::Keyboard::Left)){
flashlight.AddVelocity(sf::Vector2f(-1, 0));
}
//and
void Flashlight::AddVelocity(sf::Vector2f increment){
velocityX += increment.x;
velocityY += increment.y;
}
//return functions
sf::Vector2f &Flashlight::GetVelocity(){
if(velocityX >= MAX_FLASHLIGHT_VELOCITY.x){
velocityX = MAX_FLASHLIGHT_VELOCITY.x;
}
if(velocityY >= MAX_FLASHLIGHT_VELOCITY.y){
velocityY = MAX_FLASHLIGHT_VELOCITY.y;
}
return sf::Vector2f(velocityX, velocityY);
}
sf::Sprite Flashlight::GetLight(){
return light;
}
//and move the sprite, which is also not working
void Engine::Update(float interpolation){
if(CollisionTest() == false){
flashlight.GetLight().move(flashlight.GetVelocity().x * interpolation * .8, flashlight.GetVelocity().y * interpolation * .8);
flashlight.GetShader().setPosition(flashlight.GetLight().getPosition());
}
}
Where flashlight is an object of my new class I created.
That's everything related to my new code. I'm not sure why the sprite is now unresponsive, but any help would be appreciated.