Tasharen Entertainment Forum
Support => NGUI 3 Support => Topic started by: BehindTheStone on August 28, 2013, 12:01:38 PM
-
So I have a button and when this button is pressed it's playing a certain Animation (2DToolkit), but when the button is pressed again, the animation starts again before the last cycle of the animation could end.
Is there a way to prevent more input on the button till the moment the animation is done playing?
-
You'll have to do a little work.
Wherever you're processing your OnClick(), you should set a bool (animating). When the toolkit animation is done, call a method on your OnClick handler to set animating to false.
-
Same procedure with OnPress? The Button works with the OnPress(bool pressed) method.
-
Yeah, well, OnPress has the down/up bool sent with it, but the idea is the same. Just make sure you only fire your animation on the one you want (pressdown or release).
-
Mhm, to be honest I didn't quite understand how to prevent the second input with the animation-bool?
Some Pseudo-Code-Advice?
-
What Nicky said. PsuedoCode? Something like this maybe.
bool isAnimPlaying = false;
if (OnPress)
{
if (!isAnimPlaying)
{
PlayAnim();
isAnimPlaying = true;
}
if (IsAnimFinished())
{
isAnimPlaying = false
}
}