Welcome,
Guest
. Please
login
or
register
. Did you miss your
activation email?
French forum
Home
Help
Search
Login
Register
SFML community forums
»
Help
»
Graphics
»
[newb] Sprite for every instance?
Print
Pages: [
1
]
Author
Topic: [newb] Sprite for every instance? (Read 2924 times)
0 Members and 2 Guests are viewing this topic.
hagel
Newbie
Posts: 23
[newb] Sprite for every instance?
«
on:
November 20, 2010, 06:06:31 pm »
I don't know a lot about SFML but it makes me think that you need an sprite "object" for every instance of an actor. Is that right?
I'm transitioning from Allegro where you just pass the image and blit the part you want with srcX,srcY,width,height from a BITMAP to a buffer(and finally to the screen). Is there a way to do that in SFML? I kinda don't trust "renderApp.draw(image);", it's too abstracted.
I really want to start using SFML seriously because of the networking capabilities.
I hope you can shed some light on my curiosity.
Logged
Groogy
Hero Member
Posts: 1469
[newb] Sprite for every instance?
«
Reply #1 on:
November 20, 2010, 07:21:43 pm »
If you don't like things that is abstracted then you shouldn't really do something object-oriented.
Anyway yes, a Sprite holds the reference to an Image. This way the different data is separated and more "abstracted". sf::Image holds anything concerning the image data and a sf::Sprite instance encapsulates everything which has to do with actually rendering the image data. So every actor should have a sprite with an image set from a resource manager.
Logged
Developer and Maker of
rbSFML
and Programmer at
Paradox Development Studio
Laurent
Administrator
Hero Member
Posts: 32498
[newb] Sprite for every instance?
«
Reply #2 on:
November 20, 2010, 07:28:17 pm »
You can think of sf::Sprite as something that holds your srcX, srcY, width, height and BITMAP. And sf::Sprite::Draw is simply equivalent to Draw(srcX, srcY, width, height, BITMAP).
It's not more complicated/abstracted than that.
Logged
Laurent Gomila - SFML developer
hagel
Newbie
Posts: 23
[newb] Sprite for every instance?
«
Reply #3 on:
November 20, 2010, 07:43:43 pm »
Don't get me wrong. I like abstraction, it's just that I want a little more control over my image.
I'm just having a hard time understanding how I can make the animation simple enough. Sprite sheets and all that jazz you know.
If I want more than one frame in my animation(lol?) I need more than one Sprite in my actor instance, right? Something like Sprite spr[5]?
Logged
Groogy
Hero Member
Posts: 1469
[newb] Sprite for every instance?
«
Reply #4 on:
November 20, 2010, 07:51:27 pm »
You could but that would be inefficient.
Your interested in this function:
http://sfml-dev.org/documentation/2.0/classsf_1_1Sprite.htm#ae8e8be077534c0b8704e59b0ea4cf9a
Also I think animation has already been covered in this forum or the Wiki.
http://sfml-dev.org/wiki/en/sources
Check it out, there is several different.
Logged
Developer and Maker of
rbSFML
and Programmer at
Paradox Development Studio
Print
Pages: [
1
]
SFML community forums
»
Help
»
Graphics
»
[newb] Sprite for every instance?
anything