PDA

View Full Version : need a math formula




alexandergre
Dec 5, 2009, 02:51 PM
mybutton.location.x=158;
mylable.alpha=0;

mybutton is dragable in 259>x>158
I want the mylable.alpha to grow from 0 to 1.0 as the x grows from 158 to 259;


I came up with this:
mylabel.alpha=((myButton.location.x)/259);

It works
but the alpha start from 0.613900 and not 0. becase 158/259=0.61003861
I need another forumla. can you please help.

mylabel.alpha=((myButton.location.x-158)/259) didnt work either.
when x= 158; alpha is 0;
but when x=259 alpha is 0.39



SilentPanda
Dec 5, 2009, 03:14 PM
Get rid of the "/259". Then it will go from 0 - 99 at least. Then you just need to do "/100" to get values of 0-.99.

swiftaw
Dec 5, 2009, 03:16 PM
mylabel.alpha=((myButton.location.x - 158)/101)