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

Author Topic: Add a value to a sprite?  (Read 1271 times)

0 Members and 1 Guest are viewing this topic.

DejectedAxe

  • Newbie
  • *
  • Posts: 2
    • View Profile
Add a value to a sprite?
« 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.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Add a value to a sprite?
« Reply #1 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.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
AW: Add a value to a sprite?
« Reply #2 on: April 06, 2015, 07:44:17 pm »
Create your own entity class that lets you do such a thing.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

DejectedAxe

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Add a value to a sprite?
« Reply #3 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.