###

» Thu Jul 04, 2013 10:23 am

Of course, just tweak the function ^^

distance(sprite,target)/distance(spawn,target) (let's call this P) is going from 1 to 0, representing the proportion of the distance still to travel. If you do pow(P,X) (where X is between 0 and 1, strictly) you will get a curvy function, not linear anymore, still going from 1 to 0 (0 power X = 0 and 1 power X = 1, when X>0 so we are ok).

**Examples :**

__For X=0.5__

scale at origin is 100%

scale at 30% of the travel is 84%

scale at 50% is 71%

scale at 70% is 54%

Scale at 90% is 30%

scale at destination is 0%

__For X=0.8__

scale at origin is 100%

scale at 30% of the travel is 75%

scale at 50% is 57%

scale at 70% is 38%

Scale at 90% is 16%

scale at destination is 0%

When X approaches 1, you will get a more linear function.

When X approaches 0, you will get a more curvy function.

You just have to try now :)

EDIT : lerp would help also, it's true, but it won't work if the sprite can go both ways, or if you want to have always the same scale at the same position, because lerp will be time-dependent, "smoothing" the changes in the scale. Because of this, the scale would adjust depending on the sprite movement/speed over time, not just its position between origin and destinationGuizmus2013-07-04 10:27:17