SFML community forums

Help => General => Topic started by: sandorlev on February 25, 2013, 01:49:14 am

Title: [RESOLVED] How to copy a sprite 2+ times over the screen?
Post by: sandorlev on February 25, 2013, 01:49:14 am
Hey guys!

I am new to SFML (coming from SDL), and I have to say I'm very impressed! But I have some trouble adapting my way of thinking to SFML 2.0 and I just cannot figure out this one.

How do I render a sprite more than once at different positions on the screen (like you can with SDL_Surface)? I want to use sprites because they allow easy adaptation to any screen size through sf::Sprite::setScale.

I'm really not sure how to go about it.
Title: Re: How to copy a sprite 2+ times over the screen?
Post by: G. on February 25, 2013, 01:52:51 am
Move your sprite, draw it on the window, move it again and draw it again.

Or use the same sf::Texture for 2 different sf::Sprite, each with its own position (and rotation etc.), and draw both of them.
Do not hesitate to use multiple sprites when needed, they are inexpensive. Just don't duplicate textures.
Title: Re: How to copy a sprite 2+ times over the screen?
Post by: sandorlev on February 25, 2013, 02:11:33 am
Move your sprite, draw it on the window, move it again and draw it again.

Or use the same sf::Texture for 2 different sf::Sprite, each with its own position (and rotation etc.), and draw both of them.
Do not hesitate to use multiple sprites when needed, they are inexpensive. Just don't duplicate textures.

Thanks you for the quick answer!