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

Author Topic: sprite filled with white color  (Read 1368 times)

0 Members and 1 Guest are viewing this topic.

lorence30

  • Full Member
  • ***
  • Posts: 124
    • View Profile
    • Email
sprite filled with white color
« 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?

shadowmouse

  • Sr. Member
  • ****
  • Posts: 302
    • View Profile
Re: sprite filled with white color
« Reply #1 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.

lorence30

  • Full Member
  • ***
  • Posts: 124
    • View Profile
    • Email
Re: sprite filled with white color
« Reply #2 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

G.

  • Hero Member
  • *****
  • Posts: 1592
    • View Profile
Re: sprite filled with white color
« Reply #3 on: May 17, 2015, 06:03:35 pm »
loadAlien returns a copy of an sf::Texture which gets instantly destroyed. Return an sf::Texture&

lorence30

  • Full Member
  • ***
  • Posts: 124
    • View Profile
    • Email
Re: sprite filled with white color
« Reply #4 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

 

anything