Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: Memige on July 02, 2014, 11:02:19 AM

Title: Dynamically altering Tween duration on an active tween
Post by: Memige 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
Title: Re: Dynamically altering Tween duration on an active tween
Post by: ArenMook 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.