Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Is there any way to animate a transformation on sf::Sprite like setScale or setPosition?

ie: sprite.setScale(0.5f,0.5f);. I want the transition between normal and half scale be smooth.

Thanks!

share|improve this question

1 Answer 1

up vote 2 down vote accepted

Simply use interpolation between the two values.

A simple form:

Vector2 goalScale = new Vector2(1,1);
Vector2 resultScale = sprite.getScale();

resultScale+= (goalScale - resultScale)/2; // increase division for stronger easing

sprite.setScale(resultScale);

Alternatively use a C++ tweener library.

share|improve this answer
    
Thanks Sidar! It works, but i'll search for tweener library! –  ApheX Jun 25 '13 at 9:58

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.