Author Topic: Status/direction of UITweener  (Read 2528 times)

StridingDragon

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 53
    • View Profile
Status/direction of UITweener
« on: February 21, 2013, 02:19:25 PM »
Is it possible to find out which direction UITweener is currently set? I know that I can switch it using Toggle, but is there a way to tell whether it is currently set to go the original direction or the reverse, or rather, is there a way to tell it specifically "tween forward" or "tween reverse?"

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Status/direction of UITweener
« Reply #1 on: February 21, 2013, 10:45:42 PM »
Check the UITweener.amountPerDelta. If it's 1, it's playing forward. If it's -1, then it's reverse. Tweens are not like animations, when you play them you explicitly specify the target value that you are tweening towards from the current value. You can change the "from" value if you like though.

StridingDragon

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 53
    • View Profile
Re: Status/direction of UITweener
« Reply #2 on: February 25, 2013, 02:13:16 AM »
I can't seem to get this to work properly. UITweener.amountPerDelta always returns 1 for me, but maybe there's a different way for what I want to achieve.

When a panel is first displayed I want a button to fly into the screen - doing this through TweenPosition. When the user is finished with the screen, I want the button to fly out of the screen. I used to do this with TweenPosition.Toggle().  It seemed to work fine, but for some reason, occasionally it did not, especially when I kept going back and forth a lot for testing.  So, I tried to call TweenPosition.Reset() every time I wanted the button to fly into the screen, but that started to mess up everything. Then I tried to directly write to the to and from positions but it didn't work either.

It appears as if once the button has flown in and out, the script is no longer willing to tween. Is there some command I need to call to properly reset this or than forced the script to tween even if it has completed a tween before?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Status/direction of UITweener
« Reply #3 on: February 25, 2013, 07:15:43 AM »
Animations are better for this. You can tell them which way to play them -- forward, reverse, or toggle.