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

Author Topic: addColor method  (Read 6307 times)

0 Members and 1 Guest are viewing this topic.

MrOnlineCoder

  • Jr. Member
  • **
  • Posts: 87
    • View Profile
addColor method
« on: June 11, 2017, 03:57:12 pm »
Hello. In game, I often use some "flash" effects, or fading animations, where I change sprite/shape color like this:

sf::Color color = sprite.getColor();
color.a++;
sprite.setColor(color);
 

It will be very nice and useful if addColor method exists:
sprite.addColor(0,0,0,1);
 

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: addColor method
« Reply #1 on: June 11, 2017, 06:35:12 pm »
And then? subColor, mulColor, divColor? addPosition, subPosition, mulScale, divScale, ...? And this big mess in all SFML drawable classes? Or even in all classes, since almost every member of every class supports arithmetic operations? :P
Laurent Gomila - SFML developer

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: addColor method
« Reply #2 on: June 11, 2017, 08:33:54 pm »
What's wrong with the normal colour addition?:
sf::Color color(255, 255, 255, 0);
color += sf::Color(0, 0, 0, 1);

So, for your example it would be just:
sprite.setColor(sprite.getColor() + sf::Color(0, 0, 0, 1));
« Last Edit: June 11, 2017, 10:41:24 pm by Hapax »
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

jamesL

  • Full Member
  • ***
  • Posts: 124
    • View Profile
Re: addColor method
« Reply #3 on: June 12, 2017, 08:33:07 am »
And then? ...  addPosition, subPosition ...? And this big mess in all SFML drawable classes?

isn't that what move is ?

https://www.sfml-dev.org/documentation/2.4.2/classsf_1_1Transformable.php#ab9ca691522f6ddc1a40406849b87c469

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: addColor method
« Reply #4 on: June 12, 2017, 09:00:51 am »
Quote
isn't that what move is ?
That's right, move() should be removed.
Laurent Gomila - SFML developer

Phanoo

  • Full Member
  • ***
  • Posts: 136
    • View Profile
Re: addColor method
« Reply #5 on: August 31, 2017, 10:01:16 am »
Ideally, Laurent would like to remove everything until SFML isn't useable anymore  ;D ;D ;D

DJuego

  • Jr. Member
  • **
  • Posts: 50
    • View Profile
Re: addColor method
« Reply #6 on: August 31, 2017, 12:38:40 pm »
"The perfection is attained not when there is nothing more to add, but when there is nothing more to remove."

Antoine de Saint Exupéry

PS: And I think that Laurent is French.  :)


korczurekk

  • Full Member
  • ***
  • Posts: 150
    • View Profile
    • Email
Re: addColor method
« Reply #7 on: August 31, 2017, 07:16:50 pm »
Yep, there's no need for move tbh. I rarely used it in bigger projects.
It would be nice however, if sf::Sprite still did provide it. That's quite an important method for beginners, even though that's not a reason for it to be in sf::Transformable.