SFML community forums

Help => Graphics => Topic started by: lorence30 on May 17, 2015, 05:50:09 pm

Title: sprite filled with white color
Post by: lorence30 on May 17, 2015, 05:50:09 pm
it says that you will get white screen when the texture the sprite is pointing is no longer alive.

heres my constructor
Quote
WeirdAlien::WeirdAlien()
{
    _sprite.setTexture(loadAlien());
    alien_position[ctr].x = ctr * 32;
    ++ctr;
}

void drawAlien(const int alien_count,const std::vector<Alien*>alien,const bool isAlienAlive[6],sf::RenderWindow& game_window)
{
    for ( int a = 0; a < alien_count; a++ )
        if (isAlienAlive[a])
            game_window.draw(alien[a]->setSprite());
}

im still getting white square problem, why?
Title: Re: sprite filled with white color
Post by: shadowmouse on May 17, 2015, 05:53:24 pm
Can you give your full code? That which you've given references many functions which we can't see.
Title: Re: sprite filled with white color
Post by: lorence30 on May 17, 2015, 05:58:15 pm
Quote
Can you give your full code? That which you've given references many functions which we can't see.

http://pastebin.com/Vc73FkTa
Title: Re: sprite filled with white color
Post by: G. on May 17, 2015, 06:03:35 pm
loadAlien returns a copy of an sf::Texture which gets instantly destroyed. Return an sf::Texture&
Title: Re: sprite filled with white color
Post by: lorence30 on May 17, 2015, 06:10:27 pm
Quote
loadAlien returns a copy of an sf::Texture which gets instantly destroyed. Return an sf::Texture&
why i didnt notice that? :(

thanks