Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: lamiumthetanker on September 12, 2014, 08:56:24 AM

Title: Managing my own tween events
Post by: lamiumthetanker on September 12, 2014, 08:56:24 AM
Hi there, I'm a newbie here and I've been using NGUI 3.6.8 for a while now and I'm encountering some trouble controlling my own tweens through scripting.

The situation is, I have a menu which has a TweenTransform launching it vertically with 4 buttons on it, and in turn, each of these buttons tween in menu's from the left of the screen (they are initially hidden off-screen to the left).

Now what I am trying to accomplish, is that if a user leaves a submenu open, when they hit the main menu button, it should call the child tween FIRST, and then only on completion of that tween, should it finally call the main menu tween.

So the animation should look like this:

Step 1: User presses main menu button in bottom left corner, it tweens a vertical bar containing 4 buttons. (Done this).

Step 2: User presses one of the 4 buttons on the vertical menu, it tweens a horizontal window from off-screen in from the left to the right in behind the vertical bar. (Done this)

Step 3: User has finished with the stuff in the horizontal window, but simply clicks on the Main Menu button in the bottom left. This should first tween the horizontal window back off-screen, and on it's completion then the menu should tween in reverse back into the main menu button in the bottom left corner. (Here I have gotten as far as being able to tween them off simultaneously using my own code.)

I spotted a topic that lightly brushed on this but I don't think it works when using TweenTransform classes

Tweens
http://www.tasharen.com/forum/index.php?topic=6760.15 (http://www.tasharen.com/forum/index.php?topic=6760.15)

Here is the code that I'm currently working on (It's a custom class that is attempting to control the tweens and track their states manually)

This is the method that I'm using:
  1. public void checkStatesAndCloseMenu()
  2.     {
  3.         if (checkTween(Utils.TweenObjects.Menu) == true)
  4.         {
  5.             Debug.Log("Executing state check and closing");
  6.             foreach (Utils.TweenObjectState tween in Utils.stateTracker)
  7.             {
  8.                 if (tween.objectName != Utils.TweenObjects.Menu)
  9.                 {
  10.                     if (tween.tweened)
  11.                     {
  12.                         switch (tween.objectName)
  13.                         {
  14.                             case Utils.TweenObjects.Settings:
  15.                                 settingsButtonTween.PlayReverse();
  16.                                 toggleTweened(Utils.TweenObjects.Settings);
  17.  
  18.                                 break;
  19.                             case Utils.TweenObjects.Unit_Pool:
  20.                                 unitPoolButtonTween.PlayReverse();
  21.                                 toggleTweened(Utils.TweenObjects.Unit_Pool);
  22.                                 break;
  23.                             case Utils.TweenObjects.Air_Unit_Pool:
  24.                                 airUnitPoolButtonTween.PlayReverse();
  25.                                 toggleTweened(Utils.TweenObjects.Air_Unit_Pool);
  26.                                 break;
  27.                             case Utils.TweenObjects.Intel:
  28.                                 intelButtonTween.PlayReverse();
  29.                                 toggleTweened(Utils.TweenObjects.Intel);
  30.                                 break;
  31.                         }
  32.                     }
  33.                 }
  34.             }
  35.             menuButtonTween.PlayReverse();
  36.             toggleTweened(Utils.TweenObjects.Menu);
  37.         }
  38.         else
  39.         {
  40.             menuButtonTween.PlayForward();
  41.             toggleTweened(Utils.TweenObjects.Menu);
  42.         }
  43.     }
Title: Re: Managing my own tween events
Post by: lamiumthetanker on September 12, 2014, 09:33:45 AM
UPDATE: I fixed this issue, turns out I was just derping and didn't realise that I was typing in the EventDelegate parameter incorrectly! :-[