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

Author Topic: [RESOLVED] How to copy a sprite 2+ times over the screen?  (Read 3037 times)

0 Members and 2 Guests are viewing this topic.

sandorlev

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
[RESOLVED] How to copy a sprite 2+ times over the screen?
« 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.
« Last Edit: February 25, 2013, 02:11:47 am by sandorlev »

G.

  • Hero Member
  • *****
  • Posts: 1593
    • View Profile
Re: How to copy a sprite 2+ times over the screen?
« Reply #1 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.
« Last Edit: February 25, 2013, 01:55:01 am by G. »

sandorlev

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
Re: How to copy a sprite 2+ times over the screen?
« Reply #2 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!

 

anything