Ok so i'm trying to script something unimaginably easy but I am failing.
Basically I want to move a label from off the screen (Y value of approx 210) onto the screen based on its transparency value.
which currently looks like this
// in rep ex
gHotspot.Y = 174 + (gHotspot.Transparency / 4);
which obviously works fine.
However I dont want the movement to linear, I want the speed to slow as it gets closer to the target (y = 174).
I know i could do this with the tween module and i know i could do it by altering the dy based on the distance from the target but surely it should be possible in one line without having to declare other variables.
If you know the target and the progression through the sequence (i.e the transparency value, which is essentially a timer in this case) then you should be able to determine the position of the label.
Am I wrong?
What you want is a hyperbola inverted parabola (I guess)
Play around with this code: (factorize gHotspot.Transparency for the strength of the effect)
gHotspot.Y = 174 + Maths.Sqrt(100.0 - gHotspot.Transparency);
Also, make sure you do the appropriate xxxToxxx() conversions for the numbers or else there will be type mismatch errors. I know Calin would be able to fix this herhimself but I'll put this here as a reminder for other people who may read this thread.
gHotspot.Y = 174 + FloatToInt(Maths.Sqrt(100.0 - IntToFloat(gHotspot.Transparency)));
Also, while we're pointing out coding errors in other people's scripts..it's just IntToFloat and FloatToInt, not Maths.IntToFloat or Maths.FloatToInt. Of course the latter would fit with the OO-model better, but aren't you an avid anti-OO fanboy anyway? :P
Fixed. :=
Right. I'm a total hater for OO-style programming as it just makes stuff more complicated most of the time (and I'm not a fanboy, or whatever you want to call :P), and so I don't use the newer versions that often. It's that the xxxToxxx() functions lie in the Maths functions section that misled me into writing that (all other functions there belong to the Maths object, which is very messy as it would just made expressions unnecessarily long.