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

Author Topic: Clipped sprite?  (Read 1702 times)

0 Members and 1 Guest are viewing this topic.

Krofna

  • Newbie
  • *
  • Posts: 42
    • View Profile
    • Email
Clipped sprite?
« on: May 21, 2012, 03:35:07 pm »
This image:
http://img138.imageshack.us/img138/3944/redsolider.png

Somehow gets clipped:
http://img16.imageshack.us/img16/5748/windoww.png

Code:
extern sf::RenderWindow Window;

int Combat::MainLoop()
{
    sf::Texture CombatGUI, CreatureTexture;
    CreatureTexture.loadFromFile(enemy->CombatTextureFileName);
    CombatGUI.loadFromFile("Graphics/CombatScreen.jpg");
    CreatureSprite.setTexture(CreatureTexture);
    CreatureSprite.setPosition(320.0f, 100.0f);

    sf::Event Event;

    while(Window.isOpen())
    {
        while(Window.pollEvent(Event))
        {
            //...
        }
        Window.clear();
        Window.draw(sf::Sprite(CombatGUI));
        Window.draw(ArrowSprite);
        Window.draw(CreatureSprite);
        DrawPlayerStats();
        DrawCommandText(CommandList);
        for(auto itr = CombatTexts.begin(); itr != CombatTexts.end(); ++itr)
            Window.draw(*itr);
        Window.display();
    }
    return 2;
}

Why does that happen?

I'm using 20 days old SFML.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Clipped sprite?
« Reply #1 on: May 21, 2012, 03:42:53 pm »
Did CreatureSprite get a different texture before CreatureTexture?
Laurent Gomila - SFML developer

Krofna

  • Newbie
  • *
  • Posts: 42
    • View Profile
    • Email
Re: Clipped sprite?
« Reply #2 on: May 21, 2012, 03:48:47 pm »
Did CreatureSprite get a different texture before CreatureTexture?

Probably because Combat is a singleton... and texture rect isnt reset. Thanks for ultra fast help.

[/solved]