SFML community forums

Help => Graphics => Topic started by: DejectedAxe on April 06, 2015, 07:40:46 pm

Title: Add a value to a sprite?
Post by: DejectedAxe on April 06, 2015, 07:40:46 pm
Hi, basically I want to know if you are able to add a value to a sprite. It is likely unlikely, but basically I what I want is a "moved" value. If my sprite moved I want to set the sprites "moved" value to true. The reason in not just creating a value outside of the sprite for it is that the function returns the sprite, so I can't also return a bool.
Title: Re: Add a value to a sprite?
Post by: Nexus on April 06, 2015, 07:43:18 pm
No, you cannot.

Return a class object that contains both the sprite and the bool. Or simply std::pair (although a user-defined class is more expressive). Alternatively, use an output parameter.
Title: AW: Add a value to a sprite?
Post by: eXpl0it3r on April 06, 2015, 07:44:17 pm
Create your own entity class that lets you do such a thing.
Title: Re: Add a value to a sprite?
Post by: DejectedAxe on April 06, 2015, 07:47:33 pm
Thanks, I just wanted to see if it was possible, but both of your options are easy enough.