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.


Messages - 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.

2
Ah snap you are right! I changed the installation path to C:\lib\SFML and it didn't change in the template.

Anyways this is great, I can finally start working right away without worrying of setting up libraries, etc. Thanks for what you're doing!

3
Hm this is not working for me.

I installed Visual C++ Express 2013, downloaded the .exe and installed it.
I see the examples in my VS, but when I try to build them it just fails, telling me it can't find the SFML libraries.

Also I don't like all this pragma directives... but if that saves me set-up time, I guess it's fine.

Pages: [1]