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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - dysoco

Pages: [1]
1
Graphics / Proper way of moving an image atlas.
« on: March 11, 2014, 12:31:18 am »
Hello.

I recently implemented image atlas into my "game", basically I have the following:

class TextureAtlas {
    sf::Texture texture;
    std::map<std::string, std::shared_ptr<sf::Sprite>> sprites;
    std::shared_ptr<sf::Sprite> current;
}
 

where each shared_ptr<sf::Sprite> points to the sprite representing a region of the Texture (using IntRect). current points to the current Sprite to be drawn (you change it when reading keyboard input).

Everything is fine to this point, but now I've come across a big problem: how do I move my player?

So far I've been moving it with "player.sprite.move(x, y)", however, now I realized that when I move a sprite, the other sprites don't move: thus it's extremely confusing and they just jump around.

So my question is... what do you do? is there a way to tell the RenderTarget to draw a sprite in a certain position? (So I can keep my own sf::Vector2f position and implement my own move method). Or is moving all sprites at once the only way (which sounds inefficient)?

Any example code or tips?

Thanks.

Pages: [1]
anything