Author Topic: Dynamically altering Tween duration on an active tween  (Read 3069 times)

Memige

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 8
    • View Profile
Dynamically altering Tween duration on an active tween
« on: July 02, 2014, 11:02:19 AM »
Hey all,

My apologies if this already exists somewhere, I did a general search but was unable to find a solution.

TLDR Summary
Need tween to change speed while playing, without resetting

Details

Use case:  I have an icon on the screen that blinks when the user enters a restricted area.  They have a set time limit that they are allowed to be in the area before they get flagged for a violation (think shot clock in basket ball)  As there are other timers on the screen, and each of the four players has separate tracking for this restricted area, I don't want to confuse the players by adding a bunch of extra timers.  Thus, this icon acts as a messaging tool for the player and blinks faster the closer they get to the violation time.

Problem:  At the moment I am using a TweenAlpha component to accomplish the blinking, and am altering the duration through the standard .duration member.  This works fine through the editor, and even through code if I make the duration change before activating the tween; however, as I am trying to alter the duration while it is playing, I seem to be getting the behavior of a reset each time I change the duration.  Since I am changing the duration each frame based on the time remaining, it seems to be resetting to the start point each frame, resulting in a solid icon rather than the desired increasingly faster blinking.

Requested Solution: Is there a way I can alter the tween duration while it is playing and have it continue from where it is at, rather than restarting?


Many thanks
-Memige

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Dynamically altering Tween duration on an active tween
« Reply #1 on: July 03, 2014, 04:26:15 AM »
Why would they reset? What version of NGUI are you using? NGUI comes with a set of tutorials, one of which lets you change the tween duration on the fly, making things animate faster or slower as you drag the slider.