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

Author Topic: Taking a sprite from a image based on a rect  (Read 1500 times)

0 Members and 1 Guest are viewing this topic.

Davi

  • Newbie
  • *
  • Posts: 6
    • View Profile
Taking a sprite from a image based on a rect
« on: March 17, 2012, 03:44:10 pm »
Hey all! I'm new here, both on the forums and on the library. I came from SDL, and I think SFML does the job better, specially because I'm not the guy which cares about compatibility. Plus my projects would be too heavy to work on an Android or iOS.

Well, I will jump on right on my question.

I would like to know if there's an feature that selects just an part of a image file to be my sprite. Just like the second argument of the SDL's "SDL_LoadBMP()" function.

If there's no function like this, I'm pretty sure I could do it manually acessing the pixels of the sprite and etc. But I'm too much of a beginner to do that right now. If anyone could give me an function or explain with details how I could do that, I would appreciate.

If this is not possible yet, and has not been requested, I would like that this go to the "Feature Request" forums.

Thanks, and sorry if it's possible and already explained. I just didn't find it.

Oh, by the way, SFML 1.6 please. I would like to stick to it, but if you have any motives that I should move to SFML 2, I'm open to ideas.  :roll:

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Taking a sprite from a image based on a rect
« Reply #1 on: March 17, 2012, 04:26:17 pm »
Quote from: "Davi"
I would like to know if there's an feature that selects just an part of a image file to be my sprite. Just like the second argument of the SDL's "SDL_LoadBMP()" function.
sf::Sprite::SetSubRect() in SFML 1.6; sf::Sprite::setTextureRect() in SFML 2. The functions are explained in the documentation.

Quote from: "Davi"
Oh, by the way, SFML 1.6 please. I would like to stick to it, but if you have any motives that I should move to SFML 2, I'm open to ideas.  :roll:
SFML 2 is short before its release. It contains many bugfixes and new features, so I really recommend it, especially if you don't have much code to port from 1.6 :)
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Davi

  • Newbie
  • *
  • Posts: 6
    • View Profile
Taking a sprite from a image based on a rect
« Reply #2 on: March 17, 2012, 04:41:17 pm »
Thanks! I get the general idea. Now I will try and see if it works!  :wink:

 

anything